From cd74b611f4a36335e864f02f6be3e34dc39f711c Mon Sep 17 00:00:00 2001 From: dan Date: Fri, 22 Apr 2011 19:37:32 +0000 Subject: [PATCH 01/40] Add the start of the "uri-filenames" feature. FossilOrigin-Name: b8a8132e7148a7c90ca1352f20ab71d97b0bc4b0 --- manifest | 32 ++++--- manifest.uuid | 2 +- src/global.c | 5 +- src/main.c | 214 +++++++++++++++++++++++++++++++++++++++------- src/pager.c | 14 ++- src/pragma.c | 10 +-- src/sqlite.h.in | 2 + src/sqliteInt.h | 3 + src/test_malloc.c | 30 +++++++ src/test_vfs.c | 16 +++- src/util.c | 6 +- test/uri.test | 75 ++++++++++++++++ 12 files changed, 351 insertions(+), 58 deletions(-) create mode 100644 test/uri.test diff --git a/manifest b/manifest index bcd5754bbe..936a159dc6 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Update\sa\scomment\sin\se_createtable.test. -D 2011-04-20T13:35:44.094 +C Add\sthe\sstart\sof\sthe\s"uri-filenames"\sfeature. +D 2011-04-22T19:37:32.658 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 7a4d9524721d40ef9ee26f93f9bd6a51dba106f2 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -134,7 +134,7 @@ F src/expr.c e3cf0957c6b8faaaf7386a3bc69e53c0dc9705be F src/fault.c 160a0c015b6c2629d3899ed2daf63d75754a32bb F src/fkey.c a43ba8a005fb5efd1deeee06853e3a6120d46a91 F src/func.c 3a8cb2fb2de3e3aed7f39106daf4878d9d17fcce -F src/global.c 02335177cf6946fe5525c6f0755cf181140debf3 +F src/global.c 29bfb85611dd816b04f10fba0ca910366e128d38 F src/hash.c 458488dcc159c301b8e7686280ab209f1fb915af F src/hash.h 2894c932d84d9f892d4b4023a75e501f83050970 F src/hwtime.h d32741c8f4df852c7d959236615444e2b1063b08 @@ -143,7 +143,7 @@ F src/journal.c 552839e54d1bf76fb8f7abe51868b66acacf6a0e F src/legacy.c a199d7683d60cef73089e892409113e69c23a99f F src/lempar.c 7f026423f4d71d989e719a743f98a1cbd4e6d99e F src/loadext.c 3ae0d52da013a6326310655be6473fd472347b85 -F src/main.c a8571665d43ff18f89a49d47a281605ce5ea825e +F src/main.c 88a93debb7448053dfa7182fa4ae723a80b0644d F src/malloc.c 74c740e8ba22b806cfb980c8c0ddea1cbd54a20e F src/mem0.c 6a55ebe57c46ca1a7d98da93aaa07f99f1059645 F src/mem1.c 00bd8265c81abb665c48fea1e0c234eb3b922206 @@ -164,13 +164,13 @@ F src/os_common.h a8f95b81eca8a1ab8593d23e94f8a35f35d4078f F src/os_os2.c 4a75888ba3dfc820ad5e8177025972d74d7f2440 F src/os_unix.c d7889a0f9389c8c2e1d3b380f5aa1256c22a90e8 F src/os_win.c d149b9a7dfdd38de09afc054f8168cd3cd80630b -F src/pager.c 055239dcdfe12b3f5d97f6f01f85da01e2d6d912 +F src/pager.c 24b689bc3639d534f5fb292d2c68038b1e720527 F src/pager.h 3f8c783de1d4706b40b1ac15b64f5f896bcc78d1 F src/parse.y 12b7ebd61ea54f0e1b1083ff69cc2c8ce9353d58 F src/pcache.c 09d38c44ab275db581f7a2f6ff8b9bc7f8c0faaa F src/pcache.h c683390d50f856d4cd8e24342ae62027d1bb6050 F src/pcache1.c d548e31beafa792d1994b663a29a5303569efc4e -F src/pragma.c 49c90ab27a4339d4b5bc0b03c08cbcf20ed8d454 +F src/pragma.c 9e778decc3ee9bcaf88904b4a3b0a4360aaf0eab F src/prepare.c e64261559a3187698a3e7e6c8b001a4f4f98dab4 F src/printf.c 585a36b6a963df832cfb69505afa3a34ed5ef8a1 F src/random.c cd4a67b3953b88019f8cd4ccd81394a8ddfaba50 @@ -178,9 +178,9 @@ F src/resolve.c 1c0f32b64f8e3f555fe1f732f9d6f501a7f05706 F src/rowset.c 69afa95a97c524ba6faf3805e717b5b7ae85a697 F src/select.c d9d440809025a58547e39f4f268c2a296bfb56ff F src/shell.c 72e7e176bf46d5c6518d15ac4ad6847c4bb5df79 -F src/sqlite.h.in fe9a777d43276b4778e92b16a8b89ea6c38bb32b +F src/sqlite.h.in f8777aefc000c9e342cbc6676df168c196c2b624 F src/sqlite3ext.h c90bd5507099f62043832d73f6425d8d5c5da754 -F src/sqliteInt.h ac8f3f5846275c634f6649969304a9e97f6f9854 +F src/sqliteInt.h 810f45e3151bc4a5a273aff4b881bfc9148f92c6 F src/sqliteLimit.h 164b0e6749d31e0daa1a4589a169d31c0dec7b3d F src/status.c 7ac64842c86cec2fc1a1d0e5c16d3beb8ad332bf F src/table.c 2cd62736f845d82200acfa1287e33feb3c15d62e @@ -209,7 +209,7 @@ F src/test_intarray.c d879bbf8e4ce085ab966d1f3c896a7c8b4f5fc99 F src/test_intarray.h 489edb9068bb926583445cb02589344961054207 F src/test_journal.c 785edd54f963aefb3c1628124170a56697c68c70 F src/test_loadext.c df586c27176e3c2cb2e099c78da67bf14379a56e -F src/test_malloc.c fd6188b1501c0010fb4241ddc9f0d5ac402c688d +F src/test_malloc.c 7ca7be34e0e09ef0ed6619544552ed95732e41f6 F src/test_multiplex.c fdabd793ee7a9642c5a8a470def2347144c46d05 F src/test_multiplex.h e99c571bc4968b7a9363b661481f3934bfead61d F src/test_mutex.c a6bd7b9cf6e19d989e31392b06ac8d189f0d573e @@ -225,7 +225,7 @@ F src/test_superlock.c 2b97936ca127d13962c3605dbc9a4ef269c424cd F src/test_syscall.c 162c4ec0137a549c009bb9ecab550527743cfc5d F src/test_tclvar.c f4dc67d5f780707210d6bb0eb6016a431c04c7fa F src/test_thread.c 361ae0a0f1cbf5a28ad0388a258b104017a370c0 -F src/test_vfs.c 2ed8853c1e51ac6f9ea091f7ce4e0d618bba8b86 +F src/test_vfs.c b6bab7382f4ed27a67b204250c0c22821c6e3ae9 F src/test_vfstrace.c 2265c9895f350c8d3c39b079998fbe7481505cc1 F src/test_wholenumber.c 6129adfbe7c7444f2e60cc785927f3aa74e12290 F src/test_wsd.c 41cadfd9d97fe8e3e4e44f61a4a8ccd6f7ca8fe9 @@ -233,7 +233,7 @@ F src/tokenize.c 604607d6813e9551cf5189d899e0a25c12681080 F src/trigger.c 144cc18bb701f3286484aae4292a9531f09278c8 F src/update.c 81911be16ece3c3e7716aa18565b4814ec41f8b9 F src/utf.c d83650c3ea08f7407bd9d0839d9885241c209c60 -F src/util.c 465fe10aabf0ca7d7826a156dab919b0b65c525a +F src/util.c 914e860d21496b19a912cd14f6f7a889a22f44e1 F src/vacuum.c 05513dca036a1e7848fe18d5ed1265ac0b32365e F src/vdbe.c 05deeec6659f2579674a5e6510b3ada2a442f8d5 F src/vdbe.h 8a675fefdf7119441fe817c800a9a52440c2e797 @@ -837,6 +837,7 @@ F test/unique.test 083c7fff74695bcc27a71d75699deba3595bc9c2 F test/unixexcl.test 9d80a54d86d2261f660758928959368ffc36151e F test/unordered.test e81169ce2a8f31b2c6b66af691887e1376ab3ced F test/update.test 8bc86fd7ef1a00014f76dc6a6a7c974df4aef172 +F test/uri.test a9f84a838e73268c3fa9ed29b03512cb7baa7aca F test/utf16align.test 54cd35a27c005a9b6e7815d887718780b6a462ae F test/vacuum.test 29b60e8cc9e573b39676df6c4a75fe9e02d04a09 F test/vacuum2.test 91a84c9b08adfc4472097d2e8deb0150214e0e76 @@ -929,7 +930,10 @@ F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224 F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e F tool/split-sqlite3c.tcl d9be87f1c340285a3e081eb19b4a247981ed290c F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f -P 0dd09fc034c127718366d3a3183e367d2f9fd82d -R 056a0ea57c930302e35ea6c4f7c5b4b7 +P d8b149f5e465f7794739ed0210e1e5c53110ee9a +R f623a8b9a02395ad34296947bebabb85 +T *branch * uri +T *sym-uri * +T -sym-trunk * U dan -Z b72241c9e230cb141bfcaf5fbf022480 +Z 1128ec625dbb3b0786239aee8b2345ad diff --git a/manifest.uuid b/manifest.uuid index fde4759710..66d198381b 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -d8b149f5e465f7794739ed0210e1e5c53110ee9a \ No newline at end of file +b8a8132e7148a7c90ca1352f20ab71d97b0bc4b0 \ No newline at end of file diff --git a/src/global.c b/src/global.c index 0c890684d9..f01eaa8f4a 100644 --- a/src/global.c +++ b/src/global.c @@ -129,7 +129,9 @@ const unsigned char sqlite3CtypeMap[256] = { }; #endif - +#ifndef SQLITE_USE_URI +# define SQLITE_USE_URI 0 +#endif /* ** The following singleton contains the global configuration for @@ -139,6 +141,7 @@ SQLITE_WSD struct Sqlite3Config sqlite3Config = { SQLITE_DEFAULT_MEMSTATUS, /* bMemstat */ 1, /* bCoreMutex */ SQLITE_THREADSAFE==1, /* bFullMutex */ + SQLITE_USE_URI, /* bOpenUri */ 0x7ffffffe, /* mxStrlen */ 100, /* szLookaside */ 500, /* nLookaside */ diff --git a/src/main.c b/src/main.c index 4aaa61899c..e2bcf009b8 100644 --- a/src/main.c +++ b/src/main.c @@ -426,6 +426,11 @@ int sqlite3_config(int op, ...){ break; } + case SQLITE_CONFIG_URI: { + sqlite3GlobalConfig.bOpenUri = va_arg(ap, int); + break; + } + default: { rc = SQLITE_ERROR; break; @@ -1785,6 +1790,150 @@ int sqlite3_limit(sqlite3 *db, int limitId, int newLimit){ return oldLimit; /* IMP: R-53341-35419 */ } +/* +** This function is used to parse filenames passed by the user to API +** functions sqlite3_open() or sqlite3_open_v2(), and for database filenames +** specified as part of ATTACH statements. +*/ +int sqlite3ParseUri( + const char *zDefaultVfs, /* VFS to use if no "vfs=xxx" query option */ + const char *zUri, /* Nul-terminated URI to parse */ + int *pFlags, /* IN/OUT: SQLITE_OPEN_XXX flags */ + sqlite3_vfs **ppVfs, /* OUT: VFS to use */ + char **pzFile, /* OUT: Filename component of URI */ + char **pzErrMsg /* OUT: Error message (if rc!=SQLITE_OK) */ +){ + int flags = *pFlags; + const char *zVfs = zDefaultVfs; + char *zFile; + int nUri = sqlite3Strlen30(zUri); + + assert( *pzErrMsg==0 ); + + if( ((flags & SQLITE_OPEN_URI) || sqlite3GlobalConfig.bOpenUri) + && nUri>=5 && memcmp(zUri, "file:", 5)==0 + ){ + char *zOpt = 0; + int eState; /* Parser state when parsing URI */ + int iIn; /* Input character index */ + int iOut = 0; /* Output character index */ + int nByte = nUri+2; /* Bytes of space to allocate */ + for(iIn=0; iIn=0 && codepoint<256 ); + if( codepoint==0 ) continue; + c = codepoint; + }else if( (eState==0 && c=='?') || (eState==1 && c=='=') ){ + if( eState==0 ){ + zOpt = &zFile[iOut+1]; + } + eState++; + c = 0; + }else if( eState!=0 && c=='&' ){ + if( eState==1 ) zFile[iOut++] = '\0'; + eState = 1; + c = 0; + } + zFile[iOut++] = c; + } + if( eState==1 ) zFile[iOut++] = '\0'; + zFile[iOut++] = '\0'; + zFile[iOut++] = '\0'; + + /* Check if there were any options specified that should be interpreted + ** here. Options that are interpreted here include "vfs" and those that + ** correspond to flags that may be passed to the sqlite3_open_v2() + ** method. */ + if( zOpt ){ + struct Option { + const char *zOption; + int mask; + } aOpt [] = { + { "vfs", 0 }, + { "readonly", SQLITE_OPEN_READONLY }, + { "readwrite", SQLITE_OPEN_READWRITE }, + { "create", SQLITE_OPEN_CREATE }, + { "sharedcache", SQLITE_OPEN_SHAREDCACHE }, + { "privatecache", SQLITE_OPEN_PRIVATECACHE } + }; + + while( zOpt[0] ){ + int nOpt = sqlite3Strlen30(zOpt); + char *zVal = &zOpt[nOpt+1]; + int nVal = sqlite3Strlen30(zVal); + int i; + + for(i=0; iaModule); #endif - db->pVfs = sqlite3_vfs_find(zVfs); - if( !db->pVfs ){ - rc = SQLITE_ERROR; - sqlite3Error(db, rc, "no such vfs: %s", zVfs); - goto opendb_out; - } - /* Add the default collation sequence BINARY. BINARY works for both UTF-8 ** and UTF-16, so add a version for each to avoid any unnecessary ** conversions. The only error that can occur here is a malloc() failure. @@ -1932,9 +2058,38 @@ static int openDatabase( createCollation(db, "NOCASE", SQLITE_UTF8, SQLITE_COLL_NOCASE, 0, nocaseCollatingFunc, 0); + /* Parse the filename/URI argument. */ + rc = sqlite3ParseUri(zVfs, zFilename, &flags, &db->pVfs, &zOpen, &zErrMsg); + if( rc!=SQLITE_OK ){ + sqlite3Error(db, rc, "%s", zErrMsg); + sqlite3_free(zErrMsg); + goto opendb_out; + } + + /* Only allow sensible combinations of bits in the flags argument. + ** Throw an error if any non-sense combination is used. If we + ** do not block illegal combinations here, it could trigger + ** assert() statements in deeper layers. Sensible combinations + ** are: + ** + ** 1: SQLITE_OPEN_READONLY + ** 2: SQLITE_OPEN_READWRITE + ** 6: SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE + */ + assert( SQLITE_OPEN_READONLY == 0x01 ); + assert( SQLITE_OPEN_READWRITE == 0x02 ); + assert( SQLITE_OPEN_CREATE == 0x04 ); + testcase( (1<<(flags&7))==0x02 ); /* READONLY */ + testcase( (1<<(flags&7))==0x04 ); /* READWRITE */ + testcase( (1<<(flags&7))==0x40 ); /* READWRITE | CREATE */ + if( ((1<<(flags&7)) & 0x46)==0 ){ + rc = SQLITE_MISUSE; + goto opendb_out; + } + /* Open the backend database driver */ db->openFlags = flags; - rc = sqlite3BtreeOpen(zFilename, db, &db->aDb[0].pBt, 0, + rc = sqlite3BtreeOpen(zOpen, db, &db->aDb[0].pBt, 0, flags | SQLITE_OPEN_MAIN_DB); if( rc!=SQLITE_OK ){ if( rc==SQLITE_IOERR_NOMEM ){ @@ -2027,6 +2182,7 @@ static int openDatabase( sqlite3_wal_autocheckpoint(db, SQLITE_DEFAULT_WAL_AUTOCHECKPOINT); opendb_out: + sqlite3_free(zOpen); if( db ){ assert( db->mutex!=0 || isThreadsafe==0 || sqlite3GlobalConfig.bFullMutex==0 ); sqlite3_mutex_leave(db->mutex); diff --git a/src/pager.c b/src/pager.c index 94f647dcc9..8ad6984f8a 100644 --- a/src/pager.c +++ b/src/pager.c @@ -4299,6 +4299,8 @@ int sqlite3PagerOpen( int noReadlock = (flags & PAGER_NO_READLOCK)!=0; /* True to omit read-lock */ int pcacheSize = sqlite3PcacheSize(); /* Bytes to allocate for PCache */ u32 szPageDflt = SQLITE_DEFAULT_PAGE_SIZE; /* Default page size */ + const char *zUri = 0; /* URI args to copy */ + int nUri = 0; /* Number of bytes of URI args at *zUri */ /* Figure out how much space is required for each journal file-handle ** (there are two of them, the main journal and the sub-journal). This @@ -4329,6 +4331,7 @@ int sqlite3PagerOpen( ** leave both nPathname and zPathname set to 0. */ if( zFilename && zFilename[0] ){ + const char *z; nPathname = pVfs->mxPathname+1; zPathname = sqlite3Malloc(nPathname*2); if( zPathname==0 ){ @@ -4337,6 +4340,12 @@ int sqlite3PagerOpen( zPathname[0] = 0; /* Make sure initialized even if FullPathname() fails */ rc = sqlite3OsFullPathname(pVfs, zFilename, nPathname, zPathname); nPathname = sqlite3Strlen30(zPathname); + z = zUri = &zFilename[sqlite3Strlen30(zFilename)+1]; + while( *z ){ + z += sqlite3Strlen30(z)+1; + z += sqlite3Strlen30(z)+1; + } + nUri = &z[1] - zUri; if( rc==SQLITE_OK && nPathname+8>pVfs->mxPathname ){ /* This branch is taken when the journal path required by ** the database being opened will be more than pVfs->mxPathname @@ -4369,7 +4378,7 @@ int sqlite3PagerOpen( ROUND8(pcacheSize) + /* PCache object */ ROUND8(pVfs->szOsFile) + /* The main db file */ journalFileSize * 2 + /* The two journal files */ - nPathname + 1 + /* zFilename */ + nPathname + 1 + nUri + /* zFilename */ nPathname + 8 + 1 /* zJournal */ #ifndef SQLITE_OMIT_WAL + nPathname + 4 + 1 /* zWal */ @@ -4391,8 +4400,9 @@ int sqlite3PagerOpen( /* Fill in the Pager.zFilename and Pager.zJournal buffers, if required. */ if( zPathname ){ assert( nPathname>0 ); - pPager->zJournal = (char*)(pPtr += nPathname + 1); + pPager->zJournal = (char*)(pPtr += nPathname + 1 + nUri); memcpy(pPager->zFilename, zPathname, nPathname); + memcpy(&pPager->zFilename[nPathname+1], zUri, nUri); memcpy(pPager->zJournal, zPathname, nPathname); memcpy(&pPager->zJournal[nPathname], "-journal", 8); #ifndef SQLITE_OMIT_WAL diff --git a/src/pragma.c b/src/pragma.c index 75ab26d441..799805c40b 100644 --- a/src/pragma.c +++ b/src/pragma.c @@ -49,7 +49,7 @@ static u8 getSafetyLevel(const char *z){ /* ** Interpret the given string as a boolean value. */ -static u8 getBoolean(const char *z){ +u8 sqlite3GetBoolean(const char *z){ return getSafetyLevel(z)&1; } @@ -219,7 +219,7 @@ static int flagPragma(Parse *pParse, const char *zLeft, const char *zRight){ mask &= ~(SQLITE_ForeignKeys); } - if( getBoolean(zRight) ){ + if( sqlite3GetBoolean(zRight) ){ db->flags |= mask; }else{ db->flags &= ~mask; @@ -433,7 +433,7 @@ void sqlite3Pragma( int b = -1; assert( pBt!=0 ); if( zRight ){ - b = getBoolean(zRight); + b = sqlite3GetBoolean(zRight); } if( pId2->n==0 && b>=0 ){ int ii; @@ -1033,7 +1033,7 @@ void sqlite3Pragma( #ifndef NDEBUG if( sqlite3StrICmp(zLeft, "parser_trace")==0 ){ if( zRight ){ - if( getBoolean(zRight) ){ + if( sqlite3GetBoolean(zRight) ){ sqlite3ParserTrace(stderr, "parser: "); }else{ sqlite3ParserTrace(0, 0); @@ -1047,7 +1047,7 @@ void sqlite3Pragma( */ if( sqlite3StrICmp(zLeft, "case_sensitive_like")==0 ){ if( zRight ){ - sqlite3RegisterLikeFunctions(db, getBoolean(zRight)); + sqlite3RegisterLikeFunctions(db, sqlite3GetBoolean(zRight)); } }else diff --git a/src/sqlite.h.in b/src/sqlite.h.in index 421da8e6bd..abe5bc0080 100644 --- a/src/sqlite.h.in +++ b/src/sqlite.h.in @@ -479,6 +479,7 @@ int sqlite3_exec( #define SQLITE_OPEN_SHAREDCACHE 0x00020000 /* Ok for sqlite3_open_v2() */ #define SQLITE_OPEN_PRIVATECACHE 0x00040000 /* Ok for sqlite3_open_v2() */ #define SQLITE_OPEN_WAL 0x00080000 /* VFS only */ +#define SQLITE_OPEN_URI 0x00100000 /* Ok for sqlite3_open_v2() */ /* Reserved: 0x00F00000 */ @@ -1444,6 +1445,7 @@ struct sqlite3_mem_methods { #define SQLITE_CONFIG_PCACHE 14 /* sqlite3_pcache_methods* */ #define SQLITE_CONFIG_GETPCACHE 15 /* sqlite3_pcache_methods* */ #define SQLITE_CONFIG_LOG 16 /* xFunc, void* */ +#define SQLITE_CONFIG_URI 17 /* int */ /* ** CAPI3REF: Database Connection Configuration Options diff --git a/src/sqliteInt.h b/src/sqliteInt.h index ea0925e417..da1d42207c 100644 --- a/src/sqliteInt.h +++ b/src/sqliteInt.h @@ -2420,6 +2420,7 @@ struct Sqlite3Config { int bMemstat; /* True to enable memory status */ int bCoreMutex; /* True to enable core mutexing */ int bFullMutex; /* True to enable full mutexing */ + int bOpenUri; /* True to interpret filenames as URIs */ int mxStrlen; /* Maximum string length */ int szLookaside; /* Default lookaside buffer size */ int nLookaside; /* Default lookaside buffer count */ @@ -2655,6 +2656,7 @@ void sqlite3ExprListDelete(sqlite3*, ExprList*); int sqlite3Init(sqlite3*, char**); int sqlite3InitCallback(void*, int, char**, char**); void sqlite3Pragma(Parse*,Token*,Token*,Token*,int); +u8 sqlite3GetBoolean(const char *z); void sqlite3ResetInternalSchema(sqlite3*, int); void sqlite3BeginParse(Parse*,int); void sqlite3CommitInternalChanges(sqlite3*); @@ -2919,6 +2921,7 @@ char sqlite3ExprAffinity(Expr *pExpr); int sqlite3Atoi64(const char*, i64*, int, u8); void sqlite3Error(sqlite3*, int, const char*,...); void *sqlite3HexToBlob(sqlite3*, const char *z, int n); +u8 sqlite3HexToInt(int h); int sqlite3TwoPartName(Parse *, Token *, Token *, Token **); const char *sqlite3ErrStr(int); int sqlite3ReadSchema(Parse *pParse); diff --git a/src/test_malloc.c b/src/test_malloc.c index c63ded7035..5023dca445 100644 --- a/src/test_malloc.c +++ b/src/test_malloc.c @@ -1174,6 +1174,35 @@ static int test_config_error( return TCL_OK; } +/* +** tclcmd: sqlite3_config_uri BOOLEAN +** +** Invoke sqlite3_config() or sqlite3_db_config() with invalid +** opcodes and verify that they return errors. +*/ +static int test_config_uri( + void * clientData, + Tcl_Interp *interp, + int objc, + Tcl_Obj *CONST objv[] +){ + int rc; + int bOpenUri; + + if( objc!=2 ){ + Tcl_WrongNumArgs(interp, 1, objv, "BOOL"); + return TCL_ERROR; + } + if( Tcl_GetBooleanFromObj(interp, objv[1], &bOpenUri) ){ + return TCL_ERROR; + } + + rc = sqlite3_config(SQLITE_CONFIG_URI, bOpenUri); + Tcl_SetResult(interp, (char *)sqlite3TestErrorName(rc), TCL_VOLATILE); + + return TCL_OK; +} + /* ** Usage: ** @@ -1422,6 +1451,7 @@ int Sqlitetest_malloc_Init(Tcl_Interp *interp){ { "sqlite3_config_memstatus", test_config_memstatus ,0 }, { "sqlite3_config_lookaside", test_config_lookaside ,0 }, { "sqlite3_config_error", test_config_error ,0 }, + { "sqlite3_config_uri", test_config_uri ,0 }, { "sqlite3_db_config_lookaside",test_db_config_lookaside ,0 }, { "sqlite3_dump_memsys3", test_dump_memsys3 ,3 }, { "sqlite3_dump_memsys5", test_dump_memsys3 ,5 }, diff --git a/src/test_vfs.c b/src/test_vfs.c index 64b3cb574b..53bdca68c1 100644 --- a/src/test_vfs.c +++ b/src/test_vfs.c @@ -545,7 +545,7 @@ static int tvfsOpen( /* Evaluate the Tcl script: ** - ** SCRIPT xOpen FILENAME + ** SCRIPT xOpen FILENAME KEY-VALUE-ARGS ** ** If the script returns an SQLite error code other than SQLITE_OK, an ** error is returned to the caller. If it returns SQLITE_OK, the new @@ -554,7 +554,19 @@ static int tvfsOpen( */ Tcl_ResetResult(p->interp); if( p->pScript && p->mask&TESTVFS_OPEN_MASK ){ - tvfsExecTcl(p, "xOpen", Tcl_NewStringObj(pFd->zFilename, -1), 0, 0); + Tcl_Obj *pArg = Tcl_NewObj(); + Tcl_IncrRefCount(pArg); + if( flags&SQLITE_OPEN_MAIN_DB ){ + const char *z = &zName[strlen(zName)+1]; + while( *z ){ + Tcl_ListObjAppendElement(0, pArg, Tcl_NewStringObj(z, -1)); + z += strlen(z) + 1; + Tcl_ListObjAppendElement(0, pArg, Tcl_NewStringObj(z, -1)); + z += strlen(z) + 1; + } + } + tvfsExecTcl(p, "xOpen", Tcl_NewStringObj(pFd->zFilename, -1), pArg, 0); + Tcl_DecrRefCount(pArg); if( tvfsResultCode(p, &rc) ){ if( rc!=SQLITE_OK ) return rc; }else{ diff --git a/src/util.c b/src/util.c index 1c9b401f89..50dc591207 100644 --- a/src/util.c +++ b/src/util.c @@ -983,13 +983,12 @@ void sqlite3Put4byte(unsigned char *p, u32 v){ -#if !defined(SQLITE_OMIT_BLOB_LITERAL) || defined(SQLITE_HAS_CODEC) /* ** Translate a single byte of Hex into an integer. ** This routine only works if h really is a valid hexadecimal ** character: 0..9a..fA..F */ -static u8 hexToInt(int h){ +u8 sqlite3HexToInt(int h){ assert( (h>='0' && h<='9') || (h>='a' && h<='f') || (h>='A' && h<='F') ); #ifdef SQLITE_ASCII h += 9*(1&(h>>6)); @@ -999,7 +998,6 @@ static u8 hexToInt(int h){ #endif return (u8)(h & 0xf); } -#endif /* !SQLITE_OMIT_BLOB_LITERAL || SQLITE_HAS_CODEC */ #if !defined(SQLITE_OMIT_BLOB_LITERAL) || defined(SQLITE_HAS_CODEC) /* @@ -1016,7 +1014,7 @@ void *sqlite3HexToBlob(sqlite3 *db, const char *z, int n){ n--; if( zBlob ){ for(i=0; i Date: Sat, 23 Apr 2011 10:12:30 +0000 Subject: [PATCH 02/40] Fix parsing of %00 in uri handling code. FossilOrigin-Name: 44f0874a95408c75a296964a04eef00341abb94a --- manifest | 21 ++++----- manifest.uuid | 2 +- src/main.c | 101 +++++++++++++++++++++++++------------------ test/fts3atoken.test | 13 +++--- test/pager1.test | 2 +- test/uri.test | 29 ++++++++++--- 6 files changed, 100 insertions(+), 68 deletions(-) diff --git a/manifest b/manifest index 936a159dc6..f10443fcfd 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Add\sthe\sstart\sof\sthe\s"uri-filenames"\sfeature. -D 2011-04-22T19:37:32.658 +C Fix\sparsing\sof\s%00\sin\suri\shandling\scode. +D 2011-04-23T10:12:30.605 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 7a4d9524721d40ef9ee26f93f9bd6a51dba106f2 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -143,7 +143,7 @@ F src/journal.c 552839e54d1bf76fb8f7abe51868b66acacf6a0e F src/legacy.c a199d7683d60cef73089e892409113e69c23a99f F src/lempar.c 7f026423f4d71d989e719a743f98a1cbd4e6d99e F src/loadext.c 3ae0d52da013a6326310655be6473fd472347b85 -F src/main.c 88a93debb7448053dfa7182fa4ae723a80b0644d +F src/main.c cc9f5592000ee42e38b7086a097b19dc63518085 F src/malloc.c 74c740e8ba22b806cfb980c8c0ddea1cbd54a20e F src/mem0.c 6a55ebe57c46ca1a7d98da93aaa07f99f1059645 F src/mem1.c 00bd8265c81abb665c48fea1e0c234eb3b922206 @@ -450,7 +450,7 @@ F test/fts3al.test 07d64326e79bbdbab20ee87fc3328fbf01641c9f F test/fts3am.test 218aa6ba0dfc50c7c16b2022aac5c6be593d08d8 F test/fts3an.test a49ccadc07a2f7d646ec1b81bc09da2d85a85b18 F test/fts3ao.test b83f99f70e9eec85f27d75801a974b3f820e01f9 -F test/fts3atoken.test bbb9e63a915f3df0e35d06e0add932b5bf2d54a9 +F test/fts3atoken.test 402ef2f7c2fb4b3d4fa0587df6441c1447e799b3 F test/fts3aux1.test 719c35cbbcc04dde8e5a54a6f69851a0af9ed1f2 F test/fts3b.test e93bbb653e52afde110ad53bbd793f14fe7a8984 F test/fts3c.test fc723a9cf10b397fdfc2b32e73c53c8b1ec02958 @@ -596,7 +596,7 @@ F test/notnull.test cc7c78340328e6112a13c3e311a9ab3127114347 F test/null.test a8b09b8ed87852742343b33441a9240022108993 F test/openv2.test af02ed0a9cbc0d2a61b8f35171d4d117e588e4ec F test/oserror.test 498d8337e9d15543eb7b004fef8594bf204ff43c -F test/pager1.test d8672fd0af5f4f9b99b06283d00f01547809bebe +F test/pager1.test 2f2f93411c1c5afa44ebdaf19152e4bd4d9cb1b3 F test/pager2.test 745b911dde3d1f24ae0870bd433dfa83d7c658c1 F test/pager3.test 3856d9c80839be0668efee1b74811b1b7f7fc95f F test/pagerfault.test 9de4d3e0c59970b4c6cb8dac511fa242f335d8a7 @@ -837,7 +837,7 @@ F test/unique.test 083c7fff74695bcc27a71d75699deba3595bc9c2 F test/unixexcl.test 9d80a54d86d2261f660758928959368ffc36151e F test/unordered.test e81169ce2a8f31b2c6b66af691887e1376ab3ced F test/update.test 8bc86fd7ef1a00014f76dc6a6a7c974df4aef172 -F test/uri.test a9f84a838e73268c3fa9ed29b03512cb7baa7aca +F test/uri.test b951a30a7cde3cdd978bdbfb2484c12a521f92d4 F test/utf16align.test 54cd35a27c005a9b6e7815d887718780b6a462ae F test/vacuum.test 29b60e8cc9e573b39676df6c4a75fe9e02d04a09 F test/vacuum2.test 91a84c9b08adfc4472097d2e8deb0150214e0e76 @@ -930,10 +930,7 @@ F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224 F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e F tool/split-sqlite3c.tcl d9be87f1c340285a3e081eb19b4a247981ed290c F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f -P d8b149f5e465f7794739ed0210e1e5c53110ee9a -R f623a8b9a02395ad34296947bebabb85 -T *branch * uri -T *sym-uri * -T -sym-trunk * +P b8a8132e7148a7c90ca1352f20ab71d97b0bc4b0 +R d5dabedbe6f28cafb26739963e69b2b4 U dan -Z 1128ec625dbb3b0786239aee8b2345ad +Z 7110de44a23dae8e6e6e15b3bc372cbd diff --git a/manifest.uuid b/manifest.uuid index 66d198381b..81fe45f9fb 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -b8a8132e7148a7c90ca1352f20ab71d97b0bc4b0 \ No newline at end of file +44f0874a95408c75a296964a04eef00341abb94a \ No newline at end of file diff --git a/src/main.c b/src/main.c index e2bcf009b8..12830cdab7 100644 --- a/src/main.c +++ b/src/main.c @@ -1803,6 +1803,18 @@ int sqlite3ParseUri( char **pzFile, /* OUT: Filename component of URI */ char **pzErrMsg /* OUT: Error message (if rc!=SQLITE_OK) */ ){ + struct UriOption { + const char *zOption; + int mask; + } aOpt [] = { + { "vfs", 0 }, + { "readonly", SQLITE_OPEN_READONLY }, + { "readwrite", SQLITE_OPEN_READWRITE }, + { "create", SQLITE_OPEN_CREATE }, + { "sharedcache", SQLITE_OPEN_SHAREDCACHE }, + { "privatecache", SQLITE_OPEN_PRIVATECACHE } + }; + int flags = *pFlags; const char *zVfs = zDefaultVfs; char *zFile; @@ -1813,7 +1825,7 @@ int sqlite3ParseUri( if( ((flags & SQLITE_OPEN_URI) || sqlite3GlobalConfig.bOpenUri) && nUri>=5 && memcmp(zUri, "file:", 5)==0 ){ - char *zOpt = 0; + char *zOpt; int eState; /* Parser state when parsing URI */ int iIn; /* Input character index */ int iOut = 0; /* Output character index */ @@ -1852,18 +1864,36 @@ int sqlite3ParseUri( codepoint += sqlite3HexToInt(zUri[iIn++]); assert( codepoint>=0 && codepoint<256 ); - if( codepoint==0 ) continue; - c = codepoint; - }else if( (eState==0 && c=='?') || (eState==1 && c=='=') ){ - if( eState==0 ){ - zOpt = &zFile[iOut+1]; + if( codepoint==0 ){ + /* This branch is taken when "%00" appears within the URI. In this + ** case we ignore all text in the remainder of the path, name or + ** value currently being parsed. So ignore the current character + ** and skip to the next "?", "=" or "&", as appropriate. */ + while( zUri[iIn] && zUri[iIn]!='#' + && (eState!=0 || zUri[iIn]!='?') + && (eState!=1 || (zUri[iIn]!='=' && zUri[iIn]!='&')) + && (eState!=2 || zUri[iIn]!='&') + ){ + iIn++; + } + continue; + } + c = codepoint; + }else if( eState==1 && (c=='&' || c=='=') ){ + if( zFile[iOut-1]==0 ){ + /* An empty option name. Ignore this option altogether. */ + while( zUri[iIn] && zUri[iIn]!='#' && zUri[iIn-1]!='&' ) iIn++; + continue; + } + if( c=='&' ){ + zFile[iOut++] = '\0'; + }else{ + eState = 2; } - eState++; c = 0; - }else if( eState!=0 && c=='&' ){ - if( eState==1 ) zFile[iOut++] = '\0'; + }else if( (eState==0 && c=='?') || (eState==2 && c=='&') ){ + c = 0; eState = 1; - c = 0; } zFile[iOut++] = c; } @@ -1875,43 +1905,30 @@ int sqlite3ParseUri( ** here. Options that are interpreted here include "vfs" and those that ** correspond to flags that may be passed to the sqlite3_open_v2() ** method. */ - if( zOpt ){ - struct Option { - const char *zOption; - int mask; - } aOpt [] = { - { "vfs", 0 }, - { "readonly", SQLITE_OPEN_READONLY }, - { "readwrite", SQLITE_OPEN_READWRITE }, - { "create", SQLITE_OPEN_CREATE }, - { "sharedcache", SQLITE_OPEN_SHAREDCACHE }, - { "privatecache", SQLITE_OPEN_PRIVATECACHE } - }; + zOpt = &zFile[sqlite3Strlen30(zFile)+1]; + while( zOpt[0] ){ + int nOpt = sqlite3Strlen30(zOpt); + char *zVal = &zOpt[nOpt+1]; + int nVal = sqlite3Strlen30(zVal); + int i; - while( zOpt[0] ){ - int nOpt = sqlite3Strlen30(zOpt); - char *zVal = &zOpt[nOpt+1]; - int nVal = sqlite3Strlen30(zVal); - int i; - - for(i=0; i Date: Sat, 23 Apr 2011 15:54:54 +0000 Subject: [PATCH 03/40] Have the ATTACH command do URI interpretation in the same way as sqlite3_open() and sqlite3_open_v2() do. FossilOrigin-Name: 68240e75e87a54cde93352b0ec364d34365a8170 --- manifest | 28 ++++++++++++++-------------- manifest.uuid | 2 +- src/attach.c | 17 +++++++++++++++-- src/btree.c | 4 ++-- src/btree.h | 1 + src/build.c | 2 +- src/date.c | 2 +- src/main.c | 2 +- src/test3.c | 2 +- src/vdbe.c | 2 +- test/uri.test | 40 +++++++++++++++++++++++++++++++++++++++- 11 files changed, 77 insertions(+), 25 deletions(-) diff --git a/manifest b/manifest index f10443fcfd..de6aca8fbd 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\sparsing\sof\s%00\sin\suri\shandling\scode. -D 2011-04-23T10:12:30.605 +C Have\sthe\sATTACH\scommand\sdo\sURI\sinterpretation\sin\sthe\ssame\sway\sas\ssqlite3_open()\sand\ssqlite3_open_v2()\sdo. +D 2011-04-23T15:54:54.370 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 7a4d9524721d40ef9ee26f93f9bd6a51dba106f2 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -116,19 +116,19 @@ F sqlite3.1 6be1ad09113570e1fc8dcaff84c9b0b337db5ffc F sqlite3.pc.in ae6f59a76e862f5c561eb32a380228a02afc3cad F src/alter.c 280f5c04b11b492703a342222b3de0a999445280 F src/analyze.c a425d62e8fa9ebcb4359ab84ff0c62c6563d2e2a -F src/attach.c 7f97ca76ef2453440170929531a9c778267c0830 +F src/attach.c 79f8e5d286a2873e78d2068f35c4d6270572728f F src/auth.c 523da7fb4979469955d822ff9298352d6b31de34 F src/backup.c 986c15232757f2873dff35ee3b35cbf935fc573c F src/bitvec.c af50f1c8c0ff54d6bdb7a80e2fceca5a93670bef F src/btmutex.c 976f45a12e37293e32cae0281b15a21d48a8aaa7 -F src/btree.c 6a9164af8a2ef4612ee30b253635a9bd8e5e1b1b -F src/btree.h 11753dd46597a20702bca8746cb4caa4486a82b5 +F src/btree.c 26f8a9d6169413c5682b89b5397d20437b653154 +F src/btree.h f5d775cd6cfc7ac32a2535b70e8d2af48ef5f2ce F src/btreeInt.h 67978c014fa4f7cc874032dd3aacadd8db656bc3 -F src/build.c f09c46c66a1e7668c6ee25c9a2518aaa6842044c +F src/build.c 0132bc6631fa617a1d28ef805921f6dbac18a514 F src/callback.c 0425c6320730e6d3981acfb9202c1bed9016ad1a F src/complete.c dc1d136c0feee03c2f7550bafc0d29075e36deac F src/ctime.c 7deec4534f3b5a0c3b4a4cbadf809d321f64f9c4 -F src/date.c 1548fdac51377e4e7833251de878b4058c148e1b +F src/date.c 0d63575d484322aeb344224f6a11ab7c00373dd0 F src/delete.c 7a24fcc9a31664d145acb97ce56b6d9f249a25e4 F src/expr.c e3cf0957c6b8faaaf7386a3bc69e53c0dc9705be F src/fault.c 160a0c015b6c2629d3899ed2daf63d75754a32bb @@ -143,7 +143,7 @@ F src/journal.c 552839e54d1bf76fb8f7abe51868b66acacf6a0e F src/legacy.c a199d7683d60cef73089e892409113e69c23a99f F src/lempar.c 7f026423f4d71d989e719a743f98a1cbd4e6d99e F src/loadext.c 3ae0d52da013a6326310655be6473fd472347b85 -F src/main.c cc9f5592000ee42e38b7086a097b19dc63518085 +F src/main.c 8b4ebab18189148b702afd931efd2f40476e6e05 F src/malloc.c 74c740e8ba22b806cfb980c8c0ddea1cbd54a20e F src/mem0.c 6a55ebe57c46ca1a7d98da93aaa07f99f1059645 F src/mem1.c 00bd8265c81abb665c48fea1e0c234eb3b922206 @@ -187,7 +187,7 @@ F src/table.c 2cd62736f845d82200acfa1287e33feb3c15d62e F src/tclsqlite.c 501c9a200fd998a268be475be5858febc90b725b F src/test1.c 9ca440e80e16e53920904a0a5ac7feffb9b2c9a1 F src/test2.c 80d323d11e909cf0eb1b6fbb4ac22276483bcf31 -F src/test3.c 056093cfef69ff4227a6bdb9108564dc7f45e4bc +F src/test3.c 124ff9735fb6bb7d41de180d6bac90e7b1509432 F src/test4.c d1e5a5e904d4b444cf572391fdcb017638e36ff7 F src/test5.c e1a19845625144caf038031234a12185e40d315c F src/test6.c c7256cc21d2409486d094277d5b017e8eced44ba @@ -235,7 +235,7 @@ F src/update.c 81911be16ece3c3e7716aa18565b4814ec41f8b9 F src/utf.c d83650c3ea08f7407bd9d0839d9885241c209c60 F src/util.c 914e860d21496b19a912cd14f6f7a889a22f44e1 F src/vacuum.c 05513dca036a1e7848fe18d5ed1265ac0b32365e -F src/vdbe.c 05deeec6659f2579674a5e6510b3ada2a442f8d5 +F src/vdbe.c a7f8f72ae817f7f81a25be6e18d9a37e09b0649f F src/vdbe.h 8a675fefdf7119441fe817c800a9a52440c2e797 F src/vdbeInt.h fe8f58d305e629fff02f61f655aca1d299f1f6ae F src/vdbeapi.c e0e2672e0a96ae3f8575c8ecd02912a3e8a554a1 @@ -837,7 +837,7 @@ F test/unique.test 083c7fff74695bcc27a71d75699deba3595bc9c2 F test/unixexcl.test 9d80a54d86d2261f660758928959368ffc36151e F test/unordered.test e81169ce2a8f31b2c6b66af691887e1376ab3ced F test/update.test 8bc86fd7ef1a00014f76dc6a6a7c974df4aef172 -F test/uri.test b951a30a7cde3cdd978bdbfb2484c12a521f92d4 +F test/uri.test 72d31f90b982e65763541db45ef3cb16f797d9fc F test/utf16align.test 54cd35a27c005a9b6e7815d887718780b6a462ae F test/vacuum.test 29b60e8cc9e573b39676df6c4a75fe9e02d04a09 F test/vacuum2.test 91a84c9b08adfc4472097d2e8deb0150214e0e76 @@ -930,7 +930,7 @@ F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224 F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e F tool/split-sqlite3c.tcl d9be87f1c340285a3e081eb19b4a247981ed290c F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f -P b8a8132e7148a7c90ca1352f20ab71d97b0bc4b0 -R d5dabedbe6f28cafb26739963e69b2b4 +P 44f0874a95408c75a296964a04eef00341abb94a +R 72226daec7234c928303c103545adaa3 U dan -Z 7110de44a23dae8e6e6e15b3bc372cbd +Z b332a80681747acde88f379c7f0557c6 diff --git a/manifest.uuid b/manifest.uuid index 81fe45f9fb..7dcb2b1739 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -44f0874a95408c75a296964a04eef00341abb94a \ No newline at end of file +68240e75e87a54cde93352b0ec364d34365a8170 \ No newline at end of file diff --git a/src/attach.c b/src/attach.c index bda1c87445..7c546a5c1b 100644 --- a/src/attach.c +++ b/src/attach.c @@ -70,8 +70,12 @@ static void attachFunc( sqlite3 *db = sqlite3_context_db_handle(context); const char *zName; const char *zFile; + char *zPath = 0; + char *zErr = 0; + int flags; Db *aNew; char *zErrDyn = 0; + sqlite3_vfs *pVfs; UNUSED_PARAMETER(NotUsed); @@ -124,8 +128,17 @@ static void attachFunc( ** it to obtain the database schema. At this point the schema may ** or may not be initialised. */ - rc = sqlite3BtreeOpen(zFile, db, &aNew->pBt, 0, - db->openFlags | SQLITE_OPEN_MAIN_DB); + flags = db->openFlags; + rc = sqlite3ParseUri(db->pVfs->zName, zFile, &flags, &pVfs, &zPath, &zErr); + if( rc!=SQLITE_OK ){ + sqlite3_result_error(context, zErr, -1); + sqlite3_free(zErr); + return; + } + assert( pVfs ); + flags |= SQLITE_OPEN_MAIN_DB; + rc = sqlite3BtreeOpen(pVfs, zPath, db, &aNew->pBt, 0, flags); + sqlite3_free( zPath ); db->nDb++; if( rc==SQLITE_CONSTRAINT ){ rc = SQLITE_ERROR; diff --git a/src/btree.c b/src/btree.c index 103a1f3230..d021893241 100644 --- a/src/btree.c +++ b/src/btree.c @@ -1688,13 +1688,13 @@ static int btreeInvokeBusyHandler(void *pArg){ ** to problems with locking. */ int sqlite3BtreeOpen( + sqlite3_vfs *pVfs, /* VFS to use for this b-tree */ const char *zFilename, /* Name of the file containing the BTree database */ sqlite3 *db, /* Associated database handle */ Btree **ppBtree, /* Pointer to new Btree object written here */ int flags, /* Options */ int vfsFlags /* Flags passed through to sqlite3_vfs.xOpen() */ ){ - sqlite3_vfs *pVfs; /* The VFS to use for this btree */ BtShared *pBt = 0; /* Shared part of btree structure */ Btree *p; /* Handle to return */ sqlite3_mutex *mutexOpen = 0; /* Prevents a race condition. Ticket #3537 */ @@ -1716,6 +1716,7 @@ int sqlite3BtreeOpen( #endif assert( db!=0 ); + assert( pVfs!=0 ); assert( sqlite3_mutex_held(db->mutex) ); assert( (flags&0xff)==flags ); /* flags fit in 8 bits */ @@ -1734,7 +1735,6 @@ int sqlite3BtreeOpen( if( (vfsFlags & SQLITE_OPEN_MAIN_DB)!=0 && (isMemdb || isTempDb) ){ vfsFlags = (vfsFlags & ~SQLITE_OPEN_MAIN_DB) | SQLITE_OPEN_TEMP_DB; } - pVfs = db->pVfs; p = sqlite3MallocZero(sizeof(Btree)); if( !p ){ return SQLITE_NOMEM; diff --git a/src/btree.h b/src/btree.h index c6f6aec5df..9e3a73b3b6 100644 --- a/src/btree.h +++ b/src/btree.h @@ -42,6 +42,7 @@ typedef struct BtShared BtShared; int sqlite3BtreeOpen( + sqlite3_vfs *pVfs, /* VFS to use with this b-tree */ const char *zFilename, /* Name of database file to open */ sqlite3 *db, /* Associated database connection */ Btree **ppBtree, /* Return open Btree* here */ diff --git a/src/build.c b/src/build.c index 83a1db8400..fa2d53a14b 100644 --- a/src/build.c +++ b/src/build.c @@ -3443,7 +3443,7 @@ int sqlite3OpenTempDatabase(Parse *pParse){ SQLITE_OPEN_DELETEONCLOSE | SQLITE_OPEN_TEMP_DB; - rc = sqlite3BtreeOpen(0, db, &pBt, 0, flags); + rc = sqlite3BtreeOpen(db->pVfs, 0, db, &pBt, 0, flags); if( rc!=SQLITE_OK ){ sqlite3ErrorMsg(pParse, "unable to open a temporary database " "file for storing temporary tables"); diff --git a/src/date.c b/src/date.c index b81049aa65..5ee30c06df 100644 --- a/src/date.c +++ b/src/date.c @@ -1039,7 +1039,7 @@ static void currentTimeFunc( UNUSED_PARAMETER(argv); db = sqlite3_context_db_handle(context); - sqlite3OsCurrentTimeInt64(db->pVfs, &iT); + sqlite3OsCurrentTimeInt64(db->pVfs &iT); t = iT/1000 - 10000*(sqlite3_int64)21086676; #ifdef HAVE_GMTIME_R { diff --git a/src/main.c b/src/main.c index 12830cdab7..bb1eafb9a6 100644 --- a/src/main.c +++ b/src/main.c @@ -2106,7 +2106,7 @@ static int openDatabase( /* Open the backend database driver */ db->openFlags = flags; - rc = sqlite3BtreeOpen(zOpen, db, &db->aDb[0].pBt, 0, + rc = sqlite3BtreeOpen(db->pVfs, zOpen, db, &db->aDb[0].pBt, 0, flags | SQLITE_OPEN_MAIN_DB); if( rc!=SQLITE_OK ){ if( rc==SQLITE_IOERR_NOMEM ){ diff --git a/src/test3.c b/src/test3.c index ef004ca713..4eabdccfd6 100644 --- a/src/test3.c +++ b/src/test3.c @@ -78,7 +78,7 @@ static int btree_open( sDb.mutex = sqlite3MutexAlloc(SQLITE_MUTEX_RECURSIVE); sqlite3_mutex_enter(sDb.mutex); } - rc = sqlite3BtreeOpen(argv[1], &sDb, &pBt, 0, + rc = sqlite3BtreeOpen(sDb.pVfs, argv[1], &sDb, &pBt, 0, SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE | SQLITE_OPEN_MAIN_DB); if( rc!=SQLITE_OK ){ Tcl_AppendResult(interp, errorName(rc), 0); diff --git a/src/vdbe.c b/src/vdbe.c index 5376b08a00..3e29563a66 100644 --- a/src/vdbe.c +++ b/src/vdbe.c @@ -3132,7 +3132,7 @@ case OP_OpenEphemeral: { pCx = allocateCursor(p, pOp->p1, pOp->p2, -1, 1); if( pCx==0 ) goto no_mem; pCx->nullRow = 1; - rc = sqlite3BtreeOpen(0, db, &pCx->pBt, + rc = sqlite3BtreeOpen(db->pVfs, 0, db, &pCx->pBt, BTREE_OMIT_JOURNAL | BTREE_SINGLE | pOp->p5, vfsFlags); if( rc==SQLITE_OK ){ rc = sqlite3BtreeBeginTrans(pCx->pBt, 1); diff --git a/test/uri.test b/test/uri.test index 44dd194452..cf4197f348 100644 --- a/test/uri.test +++ b/test/uri.test @@ -47,6 +47,13 @@ foreach {tn uri file} { set DB [sqlite3_open $uri] do_test 1.$tn.2 { file exists $file } 1 sqlite3_close $DB + forcedelete $file + + do_test 1.$tn.3 { file exists $file } 0 + sqlite3 db xxx.db + execsql { ATTACH $uri AS aux } + do_test 1.$tn.4 { file exists $file } 1 + db close } @@ -73,11 +80,19 @@ foreach {tn uri kvlist} { 10 file:test.db?hello=%00world&xyz= {hello {} xyz {}} 11 file:test.db?=#ravada {} 12 file:test.db?&&&&&&&&hello=world&&&&&&& {hello world} + 13 test.db?&&&&&&&&hello=world&&&&&&& {} + 14 http:test.db?hello&world {} } { set ::arglist "" set DB [sqlite3_open $uri] - do_test 2.$tn { set ::arglist } $kvlist + do_test 2.$tn.1 { set ::arglist } $kvlist sqlite3_close $DB + + sqlite3 db xxx.db + set ::arglist "" + execsql { ATTACH $uri AS aux } + do_test 2.$tn.2 { set ::arglist } $kvlist + db close } tvfs delete @@ -88,5 +103,28 @@ do_test 3.1 { list [catch { sqlite3 db "file:test.db?vfs=nosuchvfs" } msg] $msg } {1 {no such vfs: nosuchvfs}} +#------------------------------------------------------------------------- +# Test the "readonly" URI option. +# +do_test 4.0 { + sqlite3 db test.db + db eval {CREATE TABLE t1(a, b)} + db close +} {} +foreach {tn uri ro} { + 1 "file:test.db" 0 + 2 "file:test.db?readonly=0" 0 + 3 "file:test.db?readonly=1&readwrite=0&create=0" 1 +} { + set RES(0) {0 {}} + set RES(1) {1 {attempt to write a readonly database}} + + do_test 4.$tn { + sqlite3 db $uri + catchsql { INSERT INTO t1 VALUES(1, 2) } + } $RES($ro) + db close +} + finish_test From 8e98037c1b1bc9f7b838e8e01a51df8804035bd4 Mon Sep 17 00:00:00 2001 From: dan Date: Sat, 23 Apr 2011 19:06:26 +0000 Subject: [PATCH 04/40] Test that it is now possible to use different VFSs for two databases attached to a single handle. FossilOrigin-Name: 2af51f856c6203f836d8bb62b6b79b19554886e7 --- manifest | 16 ++++++------ manifest.uuid | 2 +- src/main.c | 6 ++--- src/test_vfs.c | 60 +++++++++++++++++++++++++------------------- test/uri.test | 68 +++++++++++++++++++++++++++++++++++++++++++++++++- 5 files changed, 114 insertions(+), 38 deletions(-) diff --git a/manifest b/manifest index de6aca8fbd..71007d9576 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Have\sthe\sATTACH\scommand\sdo\sURI\sinterpretation\sin\sthe\ssame\sway\sas\ssqlite3_open()\sand\ssqlite3_open_v2()\sdo. -D 2011-04-23T15:54:54.370 +C Test\sthat\sit\sis\snow\spossible\sto\suse\sdifferent\sVFSs\sfor\stwo\sdatabases\sattached\sto\sa\ssingle\shandle. +D 2011-04-23T19:06:26.760 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 7a4d9524721d40ef9ee26f93f9bd6a51dba106f2 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -143,7 +143,7 @@ F src/journal.c 552839e54d1bf76fb8f7abe51868b66acacf6a0e F src/legacy.c a199d7683d60cef73089e892409113e69c23a99f F src/lempar.c 7f026423f4d71d989e719a743f98a1cbd4e6d99e F src/loadext.c 3ae0d52da013a6326310655be6473fd472347b85 -F src/main.c 8b4ebab18189148b702afd931efd2f40476e6e05 +F src/main.c 933d0bcf586ba7acbe2ce3f37d35c474a8306109 F src/malloc.c 74c740e8ba22b806cfb980c8c0ddea1cbd54a20e F src/mem0.c 6a55ebe57c46ca1a7d98da93aaa07f99f1059645 F src/mem1.c 00bd8265c81abb665c48fea1e0c234eb3b922206 @@ -225,7 +225,7 @@ F src/test_superlock.c 2b97936ca127d13962c3605dbc9a4ef269c424cd F src/test_syscall.c 162c4ec0137a549c009bb9ecab550527743cfc5d F src/test_tclvar.c f4dc67d5f780707210d6bb0eb6016a431c04c7fa F src/test_thread.c 361ae0a0f1cbf5a28ad0388a258b104017a370c0 -F src/test_vfs.c b6bab7382f4ed27a67b204250c0c22821c6e3ae9 +F src/test_vfs.c 0ac5b2e3da61bc385c1017890687c359746be2fd F src/test_vfstrace.c 2265c9895f350c8d3c39b079998fbe7481505cc1 F src/test_wholenumber.c 6129adfbe7c7444f2e60cc785927f3aa74e12290 F src/test_wsd.c 41cadfd9d97fe8e3e4e44f61a4a8ccd6f7ca8fe9 @@ -837,7 +837,7 @@ F test/unique.test 083c7fff74695bcc27a71d75699deba3595bc9c2 F test/unixexcl.test 9d80a54d86d2261f660758928959368ffc36151e F test/unordered.test e81169ce2a8f31b2c6b66af691887e1376ab3ced F test/update.test 8bc86fd7ef1a00014f76dc6a6a7c974df4aef172 -F test/uri.test 72d31f90b982e65763541db45ef3cb16f797d9fc +F test/uri.test 062ba42524a5042985e7994dc2289259424b60bf F test/utf16align.test 54cd35a27c005a9b6e7815d887718780b6a462ae F test/vacuum.test 29b60e8cc9e573b39676df6c4a75fe9e02d04a09 F test/vacuum2.test 91a84c9b08adfc4472097d2e8deb0150214e0e76 @@ -930,7 +930,7 @@ F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224 F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e F tool/split-sqlite3c.tcl d9be87f1c340285a3e081eb19b4a247981ed290c F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f -P 44f0874a95408c75a296964a04eef00341abb94a -R 72226daec7234c928303c103545adaa3 +P 68240e75e87a54cde93352b0ec364d34365a8170 +R 4f397b814ac53bbd808b171d5d8b418c U dan -Z b332a80681747acde88f379c7f0557c6 +Z 87fa4f3faa1bbb8cd013b95e032b042b diff --git a/manifest.uuid b/manifest.uuid index 7dcb2b1739..ac2253e166 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -68240e75e87a54cde93352b0ec364d34365a8170 \ No newline at end of file +2af51f856c6203f836d8bb62b6b79b19554886e7 \ No newline at end of file diff --git a/src/main.c b/src/main.c index bb1eafb9a6..313222f54b 100644 --- a/src/main.c +++ b/src/main.c @@ -1791,9 +1791,9 @@ int sqlite3_limit(sqlite3 *db, int limitId, int newLimit){ } /* -** This function is used to parse filenames passed by the user to API -** functions sqlite3_open() or sqlite3_open_v2(), and for database filenames -** specified as part of ATTACH statements. +** This function is used to parse URIs passed by the user to API functions +** sqlite3_open() or sqlite3_open_v2(), and for database URIs specified as +** part of ATTACH statements. */ int sqlite3ParseUri( const char *zDefaultVfs, /* VFS to use if no "vfs=xxx" query option */ diff --git a/src/test_vfs.c b/src/test_vfs.c index 53bdca68c1..ba078a0f9b 100644 --- a/src/test_vfs.c +++ b/src/test_vfs.c @@ -114,20 +114,21 @@ struct Testvfs { ** + Simulating IO errors, and ** + Invoking the Tcl callback script. */ -#define TESTVFS_SHMOPEN_MASK 0x00000001 -#define TESTVFS_SHMLOCK_MASK 0x00000010 -#define TESTVFS_SHMMAP_MASK 0x00000020 -#define TESTVFS_SHMBARRIER_MASK 0x00000040 -#define TESTVFS_SHMCLOSE_MASK 0x00000080 +#define TESTVFS_SHMOPEN_MASK 0x00000001 +#define TESTVFS_SHMLOCK_MASK 0x00000010 +#define TESTVFS_SHMMAP_MASK 0x00000020 +#define TESTVFS_SHMBARRIER_MASK 0x00000040 +#define TESTVFS_SHMCLOSE_MASK 0x00000080 -#define TESTVFS_OPEN_MASK 0x00000100 -#define TESTVFS_SYNC_MASK 0x00000200 -#define TESTVFS_DELETE_MASK 0x00000400 -#define TESTVFS_CLOSE_MASK 0x00000800 -#define TESTVFS_WRITE_MASK 0x00001000 -#define TESTVFS_TRUNCATE_MASK 0x00002000 -#define TESTVFS_ACCESS_MASK 0x00004000 -#define TESTVFS_ALL_MASK 0x00007FFF +#define TESTVFS_OPEN_MASK 0x00000100 +#define TESTVFS_SYNC_MASK 0x00000200 +#define TESTVFS_DELETE_MASK 0x00000400 +#define TESTVFS_CLOSE_MASK 0x00000800 +#define TESTVFS_WRITE_MASK 0x00001000 +#define TESTVFS_TRUNCATE_MASK 0x00002000 +#define TESTVFS_ACCESS_MASK 0x00004000 +#define TESTVFS_FULLPATHNAME_MASK 0x00008000 +#define TESTVFS_ALL_MASK 0x0001FFFF #define TESTVFS_MAX_PAGES 1024 @@ -675,6 +676,14 @@ static int tvfsFullPathname( int nOut, char *zOut ){ + Testvfs *p = (Testvfs *)pVfs->pAppData; + if( p->pScript && p->mask&TESTVFS_FULLPATHNAME_MASK ){ + int rc; + tvfsExecTcl(p, "xFullPathname", Tcl_NewStringObj(zPath, -1), 0, 0); + if( tvfsResultCode(p, &rc) ){ + if( rc!=SQLITE_OK ) return rc; + } + } return sqlite3OsFullPathname(PARENTVFS(pVfs), zPath, nOut, zOut); } @@ -1040,18 +1049,19 @@ static int testvfs_obj_cmd( char *zName; int mask; } vfsmethod [] = { - { "xShmOpen", TESTVFS_SHMOPEN_MASK }, - { "xShmLock", TESTVFS_SHMLOCK_MASK }, - { "xShmBarrier", TESTVFS_SHMBARRIER_MASK }, - { "xShmUnmap", TESTVFS_SHMCLOSE_MASK }, - { "xShmMap", TESTVFS_SHMMAP_MASK }, - { "xSync", TESTVFS_SYNC_MASK }, - { "xDelete", TESTVFS_DELETE_MASK }, - { "xWrite", TESTVFS_WRITE_MASK }, - { "xTruncate", TESTVFS_TRUNCATE_MASK }, - { "xOpen", TESTVFS_OPEN_MASK }, - { "xClose", TESTVFS_CLOSE_MASK }, - { "xAccess", TESTVFS_ACCESS_MASK }, + { "xShmOpen", TESTVFS_SHMOPEN_MASK }, + { "xShmLock", TESTVFS_SHMLOCK_MASK }, + { "xShmBarrier", TESTVFS_SHMBARRIER_MASK }, + { "xShmUnmap", TESTVFS_SHMCLOSE_MASK }, + { "xShmMap", TESTVFS_SHMMAP_MASK }, + { "xSync", TESTVFS_SYNC_MASK }, + { "xDelete", TESTVFS_DELETE_MASK }, + { "xWrite", TESTVFS_WRITE_MASK }, + { "xTruncate", TESTVFS_TRUNCATE_MASK }, + { "xOpen", TESTVFS_OPEN_MASK }, + { "xClose", TESTVFS_CLOSE_MASK }, + { "xAccess", TESTVFS_ACCESS_MASK }, + { "xFullPathname", TESTVFS_FULLPATHNAME_MASK }, }; Tcl_Obj **apElem = 0; int nElem = 0; diff --git a/test/uri.test b/test/uri.test index cf4197f348..6248381f81 100644 --- a/test/uri.test +++ b/test/uri.test @@ -13,6 +13,15 @@ set testdir [file dirname $argv0] source $testdir/tester.tcl +# Test organization: +# +# 1.*: That file names are correctly extracted from URIs. +# 2.*: That URI options (query parameters) are correctly extracted from URIs. +# 3.*: That specifying an unknown VFS causes an error. +# 4.*: Tests for specifying other options (other than "vfs"). +# 5.*: Test using a different VFS with an attached database. +# + set testprefix uri db close sqlite3_shutdown @@ -104,7 +113,9 @@ do_test 3.1 { } {1 {no such vfs: nosuchvfs}} #------------------------------------------------------------------------- -# Test the "readonly" URI option. +# Test some of the other options (other than "vfs"). +# +# TODO: Fix this after the list of options is decided. # do_test 4.0 { sqlite3 db test.db @@ -126,5 +137,60 @@ foreach {tn uri ro} { db close } +#------------------------------------------------------------------------- +# Test that things work if an ATTACHed database uses a different VFS than +# the main database. The important point is that for all operations +# involving the ATTACHed database, the correct versions of the following +# VFS are used for all operations involving the attached database. +# +# xOpen +# xDelete +# xAccess +# xFullPathname +# + +# This block of code creates two VFS - "tvfs1" and "tvfs2". Each time one +# of the above methods is called using "tvfs1", global variable ::T1(X) is +# set, where X is the file-name the method is called on. Calls to the above +# methods using "tvfs2" set entries in the global T2 array. +# +testvfs tvfs1 +tvfs1 filter {xOpen xDelete xAccess xFullPathname} +tvfs1 script tvfs1_callback +proc tvfs1_callback {method filename args} { + set ::T1([file tail $filename]) 1 +} +testvfs tvfs2 +tvfs2 filter {xOpen xDelete xAccess xFullPathname} +tvfs2 script tvfs2_callback +proc tvfs2_callback {method filename args} { + set ::T2([file tail $filename]) 1 +} + +eval forcedelete [glob test.db*] +do_test 5.1.1 { + sqlite3 db file:test.db1?vfs=tvfs1 + execsql { + ATTACH 'file:test.db2?vfs=tvfs2' AS aux; + PRAGMA main.journal_mode = PERSIST; + PRAGMA aux.journal_mode = PERSIST; + CREATE TABLE t1(a, b); + CREATE TABLE aux.t2(a, b); + PRAGMA main.journal_mode = WAL; + PRAGMA aux.journal_mode = PERSIST; + INSERT INTO t1 VALUES('x', 'y'); + INSERT INTO t2 VALUES('x', 'y'); + } + lsort [array names ::T1] +} {test.db1 test.db1-journal test.db1-wal} + +do_test 5.1.2 { + lsort [array names ::T2] +} {test.db2 test.db2-journal test.db2-wal} + +db close +tvfs1 delete +tvfs2 delete + finish_test From 78e9dd2b546eb40bdce6e61b6f34f6e761ba85b9 Mon Sep 17 00:00:00 2001 From: dan Date: Tue, 3 May 2011 10:22:32 +0000 Subject: [PATCH 05/40] Change the supported URI options to "mode" and "cache". FossilOrigin-Name: 0a694a0b27e3ce251ce313cb5d19a7637c2fa309 --- manifest | 14 ++--- manifest.uuid | 2 +- src/main.c | 141 ++++++++++++++++++++++++++++++++------------------ test/uri.test | 83 +++++++++++++++++++++++------ 4 files changed, 166 insertions(+), 74 deletions(-) diff --git a/manifest b/manifest index 5dc2612251..af1b667873 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Merge\sthe\slatest\strunk\schanges\sinto\suri\sbranch. -D 2011-05-02T17:41:01.076 +C Change\sthe\ssupported\sURI\soptions\sto\s"mode"\sand\s"cache". +D 2011-05-03T10:22:32.361 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 7a4d9524721d40ef9ee26f93f9bd6a51dba106f2 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -143,7 +143,7 @@ F src/journal.c 552839e54d1bf76fb8f7abe51868b66acacf6a0e F src/legacy.c a199d7683d60cef73089e892409113e69c23a99f F src/lempar.c 7f026423f4d71d989e719a743f98a1cbd4e6d99e F src/loadext.c 3ae0d52da013a6326310655be6473fd472347b85 -F src/main.c 933d0bcf586ba7acbe2ce3f37d35c474a8306109 +F src/main.c 8e13c02ec1992f94dcc06b4b2bc0001a79b3e68f F src/malloc.c 74c740e8ba22b806cfb980c8c0ddea1cbd54a20e F src/mem0.c 6a55ebe57c46ca1a7d98da93aaa07f99f1059645 F src/mem1.c 00bd8265c81abb665c48fea1e0c234eb3b922206 @@ -837,7 +837,7 @@ F test/unique.test 083c7fff74695bcc27a71d75699deba3595bc9c2 F test/unixexcl.test 9d80a54d86d2261f660758928959368ffc36151e F test/unordered.test e81169ce2a8f31b2c6b66af691887e1376ab3ced F test/update.test 8bc86fd7ef1a00014f76dc6a6a7c974df4aef172 -F test/uri.test 062ba42524a5042985e7994dc2289259424b60bf +F test/uri.test 2e2dea3054bc6b3e5e1bf43fbab09a847ed9eb5f F test/utf16align.test 54cd35a27c005a9b6e7815d887718780b6a462ae F test/vacuum.test 29b60e8cc9e573b39676df6c4a75fe9e02d04a09 F test/vacuum2.test 91a84c9b08adfc4472097d2e8deb0150214e0e76 @@ -931,7 +931,7 @@ F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224 F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e F tool/split-sqlite3c.tcl d9be87f1c340285a3e081eb19b4a247981ed290c F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f -P 2af51f856c6203f836d8bb62b6b79b19554886e7 f55156c5194e85c47728b8a97fde3e5f0a5c9b56 -R 5b3361d8c251d725e8fb18c102b1e7f2 +P 7fdd0786c7e0d66baf3aba4485128e16a4e5ea46 +R 9466d8a507f14eedc64f1b5ce9c925cf U dan -Z ce77508d586b51f29df902539114b8b5 +Z bebe00795592ddf7acadaf3bca1d1f57 diff --git a/manifest.uuid b/manifest.uuid index 8258359950..1c54c8762d 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -7fdd0786c7e0d66baf3aba4485128e16a4e5ea46 \ No newline at end of file +0a694a0b27e3ce251ce313cb5d19a7637c2fa309 \ No newline at end of file diff --git a/src/main.c b/src/main.c index 313222f54b..eaf0f74159 100644 --- a/src/main.c +++ b/src/main.c @@ -1803,18 +1803,7 @@ int sqlite3ParseUri( char **pzFile, /* OUT: Filename component of URI */ char **pzErrMsg /* OUT: Error message (if rc!=SQLITE_OK) */ ){ - struct UriOption { - const char *zOption; - int mask; - } aOpt [] = { - { "vfs", 0 }, - { "readonly", SQLITE_OPEN_READONLY }, - { "readwrite", SQLITE_OPEN_READWRITE }, - { "create", SQLITE_OPEN_CREATE }, - { "sharedcache", SQLITE_OPEN_SHAREDCACHE }, - { "privatecache", SQLITE_OPEN_PRIVATECACHE } - }; - + int rc = SQLITE_OK; int flags = *pFlags; const char *zVfs = zDefaultVfs; char *zFile; @@ -1864,7 +1853,12 @@ int sqlite3ParseUri( codepoint += sqlite3HexToInt(zUri[iIn++]); assert( codepoint>=0 && codepoint<256 ); - if( codepoint==0 ){ + if( codepoint>=128 ){ + *pzErrMsg = sqlite3_mprintf("invalid uri escape: %.3s", &zUri[-3]); + rc = SQLITE_ERROR; + goto parse_uri_out; + } + else if( codepoint==0 ){ /* This branch is taken when "%00" appears within the URI. In this ** case we ignore all text in the remainder of the path, name or ** value currently being parsed. So ignore the current character @@ -1904,27 +1898,70 @@ int sqlite3ParseUri( /* Check if there were any options specified that should be interpreted ** here. Options that are interpreted here include "vfs" and those that ** correspond to flags that may be passed to the sqlite3_open_v2() - ** method. */ + ** method. */ zOpt = &zFile[sqlite3Strlen30(zFile)+1]; while( zOpt[0] ){ int nOpt = sqlite3Strlen30(zOpt); char *zVal = &zOpt[nOpt+1]; int nVal = sqlite3Strlen30(zVal); - int i; - for(i=0; ilimit ){ + rc = SQLITE_PERM; + goto parse_uri_out; + } + flags = (flags & ~mask) | mode; } } @@ -1942,12 +1979,16 @@ int sqlite3ParseUri( *ppVfs = sqlite3_vfs_find(zVfs); if( *ppVfs==0 ){ *pzErrMsg = sqlite3_mprintf("no such vfs: %s", zVfs); + rc = SQLITE_ERROR; + } + parse_uri_out: + if( rc!=SQLITE_OK ){ sqlite3_free(zFile); - return SQLITE_ERROR; + zFile = 0; } *pFlags = flags; *pzFile = zFile; - return SQLITE_OK; + return rc; } @@ -1974,6 +2015,27 @@ static int openDatabase( if( rc ) return rc; #endif + /* Only allow sensible combinations of bits in the flags argument. + ** Throw an error if any non-sense combination is used. If we + ** do not block illegal combinations here, it could trigger + ** assert() statements in deeper layers. Sensible combinations + ** are: + ** + ** 1: SQLITE_OPEN_READONLY + ** 2: SQLITE_OPEN_READWRITE + ** 6: SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE + */ + assert( SQLITE_OPEN_READONLY == 0x01 ); + assert( SQLITE_OPEN_READWRITE == 0x02 ); + assert( SQLITE_OPEN_CREATE == 0x04 ); + testcase( (1<<(flags&7))==0x02 ); /* READONLY */ + testcase( (1<<(flags&7))==0x04 ); /* READWRITE */ + testcase( (1<<(flags&7))==0x40 ); /* READWRITE | CREATE */ + if( ((1<<(flags&7)) & 0x46)==0 ){ + rc = SQLITE_MISUSE; + goto opendb_out; + } + if( sqlite3GlobalConfig.bCoreMutex==0 ){ isThreadsafe = 0; }else if( flags & SQLITE_OPEN_NOMUTEX ){ @@ -2078,32 +2140,11 @@ static int openDatabase( /* Parse the filename/URI argument. */ rc = sqlite3ParseUri(zVfs, zFilename, &flags, &db->pVfs, &zOpen, &zErrMsg); if( rc!=SQLITE_OK ){ - sqlite3Error(db, rc, "%s", zErrMsg); + sqlite3Error(db, rc, zErrMsg ? "%s" : 0, zErrMsg); sqlite3_free(zErrMsg); goto opendb_out; } - /* Only allow sensible combinations of bits in the flags argument. - ** Throw an error if any non-sense combination is used. If we - ** do not block illegal combinations here, it could trigger - ** assert() statements in deeper layers. Sensible combinations - ** are: - ** - ** 1: SQLITE_OPEN_READONLY - ** 2: SQLITE_OPEN_READWRITE - ** 6: SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE - */ - assert( SQLITE_OPEN_READONLY == 0x01 ); - assert( SQLITE_OPEN_READWRITE == 0x02 ); - assert( SQLITE_OPEN_CREATE == 0x04 ); - testcase( (1<<(flags&7))==0x02 ); /* READONLY */ - testcase( (1<<(flags&7))==0x04 ); /* READWRITE */ - testcase( (1<<(flags&7))==0x40 ); /* READWRITE | CREATE */ - if( ((1<<(flags&7)) & 0x46)==0 ){ - rc = SQLITE_MISUSE; - goto opendb_out; - } - /* Open the backend database driver */ db->openFlags = flags; rc = sqlite3BtreeOpen(db->pVfs, zOpen, db, &db->aDb[0].pBt, 0, diff --git a/test/uri.test b/test/uri.test index 6248381f81..38b0740ec1 100644 --- a/test/uri.test +++ b/test/uri.test @@ -117,26 +117,77 @@ do_test 3.1 { # # TODO: Fix this after the list of options is decided. # -do_test 4.0 { - sqlite3 db test.db - db eval {CREATE TABLE t1(a, b)} - db close -} {} -foreach {tn uri ro} { - 1 "file:test.db" 0 - 2 "file:test.db?readonly=0" 0 - 3 "file:test.db?readonly=1&readwrite=0&create=0" 1 +foreach {tn mode create_ok write_ok readonly_ok} { + 1 ro 0 0 1 + 2 rw 0 1 0 + 3 rwc 1 1 0 } { - set RES(0) {0 {}} - set RES(1) {1 {attempt to write a readonly database}} + catch { db close } + forcedelete test.db - do_test 4.$tn { - sqlite3 db $uri - catchsql { INSERT INTO t1 VALUES(1, 2) } - } $RES($ro) + set A(1) {0 {}} + set A(0) {1 {unable to open database file}} + do_test 4.1.$tn.1 { + list [catch {sqlite3 db "file:test.db?mode=$mode"} msg] $msg + } $A($create_ok) + + catch { db close } + forcedelete test.db + sqlite3 db test.db + db eval { CREATE TABLE t1(a, b) } db close + + set A(1) {0 {}} + set A(0) {1 {attempt to write a readonly database}} + do_test 4.1.$tn.2 { + sqlite3 db "file:test.db?mode=$mode" + catchsql { INSERT INTO t1 VALUES(1, 2) } + } $A($write_ok) + + set A(1) {0 {}} + set A(0) {1 {access permission denied}} + do_test 4.1.$tn.3 { + list [catch {sqlite3 db "file:test.db?mode=$mode" -readonly 1} msg] $msg + } $A($readonly_ok) } +set orig [sqlite3_enable_shared_cache] +foreach {tn options sc_default is_shared} { + 1 "" 1 1 + 2 "cache=private" 1 0 + 3 "cache=shared" 1 1 + 4 "" 0 0 + 5 "cache=private" 0 0 + 6 "cache=shared" 0 1 +} { + catch { db close } + forcedelete test.db + + sqlite3_enable_shared_cache 1 + sqlite3 db2 test.db + db2 eval {CREATE TABLE t1(a, b)} + + sqlite3_enable_shared_cache $sc_default + sqlite3 db "file:test.db?$options" + db eval {SELECT * FROM t1} + + set A(1) {1 {database table is locked: t1}} + set A(0) {0 {}} + do_test 4.2.$tn { + db2 eval {BEGIN; INSERT INTO t1 VALUES(1, 2);} + catchsql { SELECT * FROM t1 } + } $A($is_shared) + + db2 close +} + +do_test 4.3.1 { + list [catch {sqlite3 db "file:test.db?mode=rc"} msg] $msg +} {1 {no such access mode: rc}} +do_test 4.3.2 { + list [catch {sqlite3 db "file:test.db?cache=public"} msg] $msg +} {1 {no such cache mode: public}} + #------------------------------------------------------------------------- # Test that things work if an ATTACHed database uses a different VFS than # the main database. The important point is that for all operations @@ -177,7 +228,7 @@ do_test 5.1.1 { CREATE TABLE t1(a, b); CREATE TABLE aux.t2(a, b); PRAGMA main.journal_mode = WAL; - PRAGMA aux.journal_mode = PERSIST; + PRAGMA aux.journal_mode = WAL; INSERT INTO t1 VALUES('x', 'y'); INSERT INTO t2 VALUES('x', 'y'); } From 3b18a9a334fda27b278b9f37988650ab9d2a8b4f Mon Sep 17 00:00:00 2001 From: dan Date: Tue, 3 May 2011 11:53:20 +0000 Subject: [PATCH 06/40] Allow only "localhost" and "" as authorities in URIs. Do not allow escapes (%HH) in the authority part of a URI. FossilOrigin-Name: b8a0f1b523d1f31c8e7a102ba4bae5935b07104a --- manifest | 14 +++++++------- manifest.uuid | 2 +- src/main.c | 7 +++++++ test/uri.test | 25 ++++++++++++++++++++++--- 4 files changed, 37 insertions(+), 11 deletions(-) diff --git a/manifest b/manifest index af1b667873..abda20b79f 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Change\sthe\ssupported\sURI\soptions\sto\s"mode"\sand\s"cache". -D 2011-05-03T10:22:32.361 +C Allow\sonly\s"localhost"\sand\s""\sas\sauthorities\sin\sURIs.\sDo\snot\sallow\sescapes\s(%HH)\sin\sthe\sauthority\spart\sof\sa\sURI. +D 2011-05-03T11:53:20.345 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 7a4d9524721d40ef9ee26f93f9bd6a51dba106f2 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -143,7 +143,7 @@ F src/journal.c 552839e54d1bf76fb8f7abe51868b66acacf6a0e F src/legacy.c a199d7683d60cef73089e892409113e69c23a99f F src/lempar.c 7f026423f4d71d989e719a743f98a1cbd4e6d99e F src/loadext.c 3ae0d52da013a6326310655be6473fd472347b85 -F src/main.c 8e13c02ec1992f94dcc06b4b2bc0001a79b3e68f +F src/main.c 28da02efcab49fd4cc51008b5f6d27b742682807 F src/malloc.c 74c740e8ba22b806cfb980c8c0ddea1cbd54a20e F src/mem0.c 6a55ebe57c46ca1a7d98da93aaa07f99f1059645 F src/mem1.c 00bd8265c81abb665c48fea1e0c234eb3b922206 @@ -837,7 +837,7 @@ F test/unique.test 083c7fff74695bcc27a71d75699deba3595bc9c2 F test/unixexcl.test 9d80a54d86d2261f660758928959368ffc36151e F test/unordered.test e81169ce2a8f31b2c6b66af691887e1376ab3ced F test/update.test 8bc86fd7ef1a00014f76dc6a6a7c974df4aef172 -F test/uri.test 2e2dea3054bc6b3e5e1bf43fbab09a847ed9eb5f +F test/uri.test 858abdea53ac46844d52ba953fba78f15f0a463a F test/utf16align.test 54cd35a27c005a9b6e7815d887718780b6a462ae F test/vacuum.test 29b60e8cc9e573b39676df6c4a75fe9e02d04a09 F test/vacuum2.test 91a84c9b08adfc4472097d2e8deb0150214e0e76 @@ -931,7 +931,7 @@ F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224 F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e F tool/split-sqlite3c.tcl d9be87f1c340285a3e081eb19b4a247981ed290c F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f -P 7fdd0786c7e0d66baf3aba4485128e16a4e5ea46 -R 9466d8a507f14eedc64f1b5ce9c925cf +P 0a694a0b27e3ce251ce313cb5d19a7637c2fa309 +R afa0474b6eff205d0a5c2d2e9845accd U dan -Z bebe00795592ddf7acadaf3bca1d1f57 +Z 0ad689b41032f94f1c384beb1085aa09 diff --git a/manifest.uuid b/manifest.uuid index 1c54c8762d..dd3568cd73 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -0a694a0b27e3ce251ce313cb5d19a7637c2fa309 \ No newline at end of file +b8a0f1b523d1f31c8e7a102ba4bae5935b07104a \ No newline at end of file diff --git a/src/main.c b/src/main.c index eaf0f74159..bb4b1feba9 100644 --- a/src/main.c +++ b/src/main.c @@ -1828,6 +1828,13 @@ int sqlite3ParseUri( if( zUri[5]=='/' && zUri[6]=='/' ){ iIn = 7; while( zUri[iIn] && zUri[iIn]!='/' ) iIn++; + + if( iIn!=7 && (iIn!=16 || memcmp("localhost", &zUri[7], 9)) ){ + *pzErrMsg = sqlite3_mprintf("invalid uri authority: %.*s", + iIn-7, &zUri[7]); + rc = SQLITE_ERROR; + goto parse_uri_out; + } }else{ iIn = 5; } diff --git a/test/uri.test b/test/uri.test index 38b0740ec1..2da6574204 100644 --- a/test/uri.test +++ b/test/uri.test @@ -33,7 +33,7 @@ sqlite3_config_uri 1 foreach {tn uri file} { 1 test.db test.db 2 file:test.db test.db - 3 file://an-authorityPWD/test.db test.db + 3 file://PWD/test.db test.db 4 file:PWD/test.db test.db 5 file:test.db?mork=1 test.db 6 file:test.db?mork=1&tonglor=2 test.db @@ -44,7 +44,7 @@ foreach {tn uri file} { 11 file:test%2Edb test.db 12 file file 13 http:test.db http:test.db - 14 file://xyzPWD/test.db%3Fhello test.db?hello + 14 file://localhostPWD/test.db%3Fhello test.db?hello 15 file:test.db%00extra test.db 16 file:test%00.db%00extra test } { @@ -65,7 +65,6 @@ foreach {tn uri file} { db close } - #------------------------------------------------------------------------- # Test that URI query parameters are passed through to the VFS layer # correctly. @@ -243,5 +242,25 @@ db close tvfs1 delete tvfs2 delete +#------------------------------------------------------------------------- +# Check that only "" and "localhost" are acceptable as authorities. +# +catch {db close} +foreach {tn uri res} { + 1 "file://localhost/PWD/test.db" {not an error} + 2 "file:///PWD/test.db" {not an error} + 3 "file:/PWD/test.db" {not an error} + 4 "file://l%6Fcalhost/PWD/test.db" {invalid uri authority: l%6Fcalhost} + 5 "file://lbcalhost/PWD/test.db" {invalid uri authority: lbcalhost} + 6 "file://x/PWD/test.db" {invalid uri authority: x} +} { + set uri [string map [list PWD [string range [pwd] 1 end]] $uri] + do_test 6.$tn { + set DB [sqlite3_open $uri] + sqlite3_errmsg $DB + } $res + catch { sqlite3_close $DB } +} + finish_test From 6d49e25613d528f2d52df7d6636725fab126e565 Mon Sep 17 00:00:00 2001 From: dan Date: Tue, 3 May 2011 15:09:05 +0000 Subject: [PATCH 07/40] Remove some unused code related to URI parsing. FossilOrigin-Name: 008cd0ef6b504cf4549468f795aa46f8472f0130 --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/main.c | 15 +++++---------- 3 files changed, 12 insertions(+), 17 deletions(-) diff --git a/manifest b/manifest index abda20b79f..9799fa5daf 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Allow\sonly\s"localhost"\sand\s""\sas\sauthorities\sin\sURIs.\sDo\snot\sallow\sescapes\s(%HH)\sin\sthe\sauthority\spart\sof\sa\sURI. -D 2011-05-03T11:53:20.345 +C Remove\ssome\sunused\scode\srelated\sto\sURI\sparsing. +D 2011-05-03T15:09:05.969 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 7a4d9524721d40ef9ee26f93f9bd6a51dba106f2 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -143,7 +143,7 @@ F src/journal.c 552839e54d1bf76fb8f7abe51868b66acacf6a0e F src/legacy.c a199d7683d60cef73089e892409113e69c23a99f F src/lempar.c 7f026423f4d71d989e719a743f98a1cbd4e6d99e F src/loadext.c 3ae0d52da013a6326310655be6473fd472347b85 -F src/main.c 28da02efcab49fd4cc51008b5f6d27b742682807 +F src/main.c 872493d84fed9b9c910e1b7b2427a3e28dbe995a F src/malloc.c 74c740e8ba22b806cfb980c8c0ddea1cbd54a20e F src/mem0.c 6a55ebe57c46ca1a7d98da93aaa07f99f1059645 F src/mem1.c 00bd8265c81abb665c48fea1e0c234eb3b922206 @@ -931,7 +931,7 @@ F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224 F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e F tool/split-sqlite3c.tcl d9be87f1c340285a3e081eb19b4a247981ed290c F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f -P 0a694a0b27e3ce251ce313cb5d19a7637c2fa309 -R afa0474b6eff205d0a5c2d2e9845accd +P b8a0f1b523d1f31c8e7a102ba4bae5935b07104a +R 2dc3488a634991eebc6008406cc86975 U dan -Z 0ad689b41032f94f1c384beb1085aa09 +Z 271aa5bc20c9ebf896bbbb0905472291 diff --git a/manifest.uuid b/manifest.uuid index dd3568cd73..267cf9b4d4 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -b8a0f1b523d1f31c8e7a102ba4bae5935b07104a \ No newline at end of file +008cd0ef6b504cf4549468f795aa46f8472f0130 \ No newline at end of file diff --git a/src/main.c b/src/main.c index bb4b1feba9..9021b8514b 100644 --- a/src/main.c +++ b/src/main.c @@ -1856,16 +1856,11 @@ int sqlite3ParseUri( && sqlite3Isxdigit(zUri[iIn]) && sqlite3Isxdigit(zUri[iIn+1]) ){ - int codepoint = (sqlite3HexToInt(zUri[iIn++]) << 4); - codepoint += sqlite3HexToInt(zUri[iIn++]); + int octet = (sqlite3HexToInt(zUri[iIn++]) << 4); + octet += sqlite3HexToInt(zUri[iIn++]); - assert( codepoint>=0 && codepoint<256 ); - if( codepoint>=128 ){ - *pzErrMsg = sqlite3_mprintf("invalid uri escape: %.3s", &zUri[-3]); - rc = SQLITE_ERROR; - goto parse_uri_out; - } - else if( codepoint==0 ){ + assert( octet>=0 && octet<256 ); + if( octet==0 ){ /* This branch is taken when "%00" appears within the URI. In this ** case we ignore all text in the remainder of the path, name or ** value currently being parsed. So ignore the current character @@ -1879,7 +1874,7 @@ int sqlite3ParseUri( } continue; } - c = codepoint; + c = octet; }else if( eState==1 && (c=='&' || c=='=') ){ if( zFile[iOut-1]==0 ){ /* An empty option name. Ignore this option altogether. */ From 00142d70a933a36289f9f74720d9da44b72b405e Mon Sep 17 00:00:00 2001 From: dan Date: Thu, 5 May 2011 12:35:33 +0000 Subject: [PATCH 08/40] Fix a problem in the URI code preventing the amalgamation from building. Add comments describing SQLITE_CONFIG_URI and SQLITE_OPEN_URI to sqlite.h.in. FossilOrigin-Name: ea562d6d67c2f2ef8baca02a77634c21b945196f --- manifest | 14 +++--- manifest.uuid | 2 +- src/sqlite.h.in | 119 ++++++++++++++++++++++++++++++++++++++++++++++-- src/sqliteInt.h | 1 + 4 files changed, 123 insertions(+), 13 deletions(-) diff --git a/manifest b/manifest index 0ff82c27c9..32e0f8fc68 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Merge\slatest\strunk\schanges\swith\suri\sbranch. -D 2011-05-04T17:35:12.663 +C Fix\sa\sproblem\sin\sthe\sURI\scode\spreventing\sthe\samalgamation\sfrom\sbuilding.\sAdd\scomments\sdescribing\sSQLITE_CONFIG_URI\sand\sSQLITE_OPEN_URI\sto\ssqlite.h.in. +D 2011-05-05T12:35:33.316 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 7a4d9524721d40ef9ee26f93f9bd6a51dba106f2 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -179,9 +179,9 @@ F src/resolve.c 1c0f32b64f8e3f555fe1f732f9d6f501a7f05706 F src/rowset.c 69afa95a97c524ba6faf3805e717b5b7ae85a697 F src/select.c d9d440809025a58547e39f4f268c2a296bfb56ff F src/shell.c 72e7e176bf46d5c6518d15ac4ad6847c4bb5df79 -F src/sqlite.h.in 90b126a4e8515126799e6e2b7f5ba962283e38bd +F src/sqlite.h.in f865bde9a0af4cd77b85265df71a9d760e5def18 F src/sqlite3ext.h c90bd5507099f62043832d73f6425d8d5c5da754 -F src/sqliteInt.h d1794da98180a15974a5539eec5410187371adda +F src/sqliteInt.h 5a7bf51f767fb67b484f09d73cccff683731af22 F src/sqliteLimit.h 164b0e6749d31e0daa1a4589a169d31c0dec7b3d F src/status.c 7ac64842c86cec2fc1a1d0e5c16d3beb8ad332bf F src/table.c 2cd62736f845d82200acfa1287e33feb3c15d62e @@ -934,7 +934,7 @@ F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224 F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e F tool/split-sqlite3c.tcl d9be87f1c340285a3e081eb19b4a247981ed290c F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f -P 008cd0ef6b504cf4549468f795aa46f8472f0130 8f9666af5f9459cbd0305a86281d745ea6163acf -R 07deaa464fe0e27da6566a9a8b8c931b +P af279f367e01732560b8b2b6aeb5ede4f04415dd +R b650932bbc0e364498f81d36888b653d U dan -Z 357fb32ea4341029d4a78088d4acc043 +Z 505d1fe8270a91e9ebfb3524cd8d9a43 diff --git a/manifest.uuid b/manifest.uuid index 4ff58741bc..9a80005ad0 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -af279f367e01732560b8b2b6aeb5ede4f04415dd \ No newline at end of file +ea562d6d67c2f2ef8baca02a77634c21b945196f \ No newline at end of file diff --git a/src/sqlite.h.in b/src/sqlite.h.in index 50c9e1f594..d394d6c819 100644 --- a/src/sqlite.h.in +++ b/src/sqlite.h.in @@ -1427,6 +1427,18 @@ struct sqlite3_mem_methods { ** In a multi-threaded application, the application-defined logger ** function must be threadsafe. ** +**
SQLITE_CONFIG_URI +**
This option takes a single argument of type int. If non-zero, then +** URI handling is globally enabled. If the parameter is zero, then URI handling +** is globally disabled. If URI handling is globally enabled, all filenames +** passed to [sqlite3_open()], [sqlite3_open_v2()], [sqlite3_open16()] or +** specified as part of [ATTACH] commands are interpreted as URIs, regardless +** of whether or not the [SQLITE_OPEN_URI] flag is set when the database +** connection is opened. If it is globally disabled, filenames are +** only interpreted as URIs if the SQLITE_OPEN_URI flag is set when the +** database connection is opened. By default, URI handling is globally +** disabled. The default value may be changed by compiling with the +** [SQLITE_USE_URI] symbol defined. ** */ #define SQLITE_CONFIG_SINGLETHREAD 1 /* nil */ @@ -2322,7 +2334,7 @@ void sqlite3_progress_handler(sqlite3*, int, int(*)(void*), void*); /* ** CAPI3REF: Opening A New Database Connection ** -** ^These routines open an SQLite database file whose name is given by the +** ^These routines open an SQLite database file as specified by the ** filename argument. ^The filename argument is interpreted as UTF-8 for ** sqlite3_open() and sqlite3_open_v2() and as UTF-16 in the native byte ** order for sqlite3_open16(). ^(A [database connection] handle is usually @@ -2385,6 +2397,11 @@ void sqlite3_progress_handler(sqlite3*, int, int(*)(void*), void*); ** [SQLITE_OPEN_PRIVATECACHE] flag causes the database connection to not ** participate in [shared cache mode] even if it is enabled. ** +** ^The fourth parameter to sqlite3_open_v2() is the name of the +** [sqlite3_vfs] object that defines the operating system interface that +** the new database connection should use. ^If the fourth parameter is +** a NULL pointer then the default [sqlite3_vfs] object is used. +** ** ^If the filename is ":memory:", then a private, temporary in-memory database ** is created for the connection. ^This in-memory database will vanish when ** the database connection is closed. Future versions of SQLite might @@ -2397,10 +2414,102 @@ void sqlite3_progress_handler(sqlite3*, int, int(*)(void*), void*); ** on-disk database will be created. ^This private database will be ** automatically deleted as soon as the database connection is closed. ** -** ^The fourth parameter to sqlite3_open_v2() is the name of the -** [sqlite3_vfs] object that defines the operating system interface that -** the new database connection should use. ^If the fourth parameter is -** a NULL pointer then the default [sqlite3_vfs] object is used. +** ^If URI filename interpretation is enabled, and the filename argument +** begins with "file:", then the filename is interpreted as a URI. ^URI +** filename interpretation is enabled if the [SQLITE_OPEN_URI] flag is +** is set in the fourth argument to sqlite3_open_v2(), or if it has +** been enabled globally using the [SQLITE_CONFIG_URI] option with the +** [sqlite3_config()] method. +** +** URI filenames are parsed according to RFC 1738. If the URI contains an +** 'authority', then it must be either an empty string or the string +** "localhost". ^If the authority is not an empty string or "localhost", an +** error is returned to the caller. ^The 'fragment' component of a URI, if +** present, is always ignored. +** +** ^SQLite uses the 'path' component of the URI as the path to the database file +** to open. ^If the path begins with a '/' character, then it is interpreted as +** an absolute path. ^If it does not begin with a '/', it is interpreted as a +** relative path. ^On windows, if the first component of an absolute path is +** of the form "X:", where "X" is any alphabetic character, it is interpreted +** as a drive specification. ^Otherwise, the absolute path is interpreted as +** the full pathname of a file on the current drive. +** +** The query component of a URI may contain parameters that are interpreted +** either by SQLite itself, or by a [sqlite3_vfs | custom VFS implementation]. +** SQLite interprets the following three query parameters: +** +**
    +**
  • vfs: ^The "vfs" parameter may be used to specify the name of +** a VFS object that provides the operating system interface that should +** be used to access the database file on disk. ^If this option is set to +** an empty string the default VFS object is used. ^Specifying an unknown +** VFS is an error. +** +**
  • mode: ^(This option may be set to either "ro", "rw" or "rwc". +** Attempting to set it to any other value is an error)^. ^If "ro" is +** specified, then the database is opened for read-only access, just as if +** the [SQLITE_OPEN_READONLY] flag had been set in the third argument to +** sqlite3_prepare_v2(). ^If the mode option is set to "rw", then the +** database is opened for read-write (but not create) access, as if +** SQLITE_OPEN_READWRITE (but not SQLITE_OPEN_CREATE) had been set. +** ^Value "rwc" is equivalent to setting both SQLITE_OPEN_READWRITE and +** SQLITE_OPEN_CREATE. +** ^If sqlite3_open_v2() is used, it is an error to specify a value for +** the mode parameter that is less restrictive than that specified by the +** flags passed as the third parameter. +** +**
  • cache: ^The cache parameter may be set to either "shared" or +** "private". ^Setting it to "shared" is equivalent to setting the +** SQLITE_OPEN_SHAREDCACHE bit in the flags argument passed to +** sqlite3_open_v2(). ^Setting the cache parameter to "private" is +** equivalent to setting the SQLITE_OPEN_PRIVATECACHE bit. +** ^If sqlite3_open_v2() is used and the "cache" parameter is present in +** a URI filename, its value overrides any behaviour requested by setting +** SQLITE_OPEN_PRIVATECACHE or SQLITE_OPEN_SHAREDCACHE flag. +**
+** +** ^Specifying an unknown parameter in the query component of a URI is not an +** error. +** +** URI filename examples: +** +** +**
URI filenames Results +**
file:data.db +** Open the file "data.db" in the current directory. +**
file:/home/fred/data.db
+** file:///home/fred/data.db
+** file://localhost/home/fred/data.db
+** Open the database file "/home/fred/data.db". +**
file://darkstar/home/fred/data.db +** An error. "darkstar" is not a recognized authority. +**
+** file:///C:/Documents%20and%20Settings/fred/Desktop/data.db +** Windows only: Open the file "data.db" on fred's desktop on drive +** C:. If the "C:/" component were omitted from this URI, then the +** file "\Documents and Settings\fred\Desktop\data.db" would be opened +** on the current drive. Note that the %20 escaping in this example +** is not strictly necessary - space characters can be used literally +** in URI filenames. +**
file:data.db?mode=ro&cache=private +** Open file "data.db" in the current directory for read-only access. +** Regardless of whether or not shared-cache mode is enabled by +** default, use a private cache. +**
file:/home/fred/data.db?vfs=unix-nolock +** Open file "/home/fred/data.db". Use the special VFS "unix-nolock". +**
file:data.db?mode=readonly +** An error. "readonly" is not a valid option for the "mode" parameter. +**
+** +** ^URI hexadecimal escape sequences (%HH) are supported within the path and +** query components of a URI. A hexadecimal escape sequence consists of a +** percent sign - "%" - followed by exactly two hexadecimal digits +** specifying an octet value. ^Before the path or query components of a +** URI filename are interpreted, they are encoded using UTF-8 and all +** hexadecimal escape sequences replaced by a single byte containing the +** corresponding octet. If this process generates an invalid UTF-8 encoding, +** the results are undefined. ** ** Note to Windows users: The encoding used for the filename argument ** of sqlite3_open() and sqlite3_open_v2() must be UTF-8, not whatever diff --git a/src/sqliteInt.h b/src/sqliteInt.h index f5608c9ef1..8e18b0f399 100644 --- a/src/sqliteInt.h +++ b/src/sqliteInt.h @@ -2674,6 +2674,7 @@ void sqlite3AddColumnType(Parse*,Token*); void sqlite3AddDefaultValue(Parse*,ExprSpan*); void sqlite3AddCollateType(Parse*, Token*); void sqlite3EndTable(Parse*,Token*,Token*,Select*); +int sqlite3ParseUri(const char*,const char*,int*,sqlite3_vfs**,char**,char **); Bitvec *sqlite3BitvecCreate(u32); int sqlite3BitvecTest(Bitvec*, u32); From 2e5a422eee1c2c9d1e87de910c2b165952bfdffa Mon Sep 17 00:00:00 2001 From: drh Date: Thu, 5 May 2011 17:00:51 +0000 Subject: [PATCH 09/40] Fix a bug in memory usage tracking that was introduced by check-in [4e33a0eaf83922]. FossilOrigin-Name: 8ba456ae0b3d0c0b6f72f98bd0bc28f72dfa4ff5 --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/malloc.c | 4 ++-- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/manifest b/manifest index edcbb7b26a..0226ba2e1c 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Bump\sthe\sversion\snumber\sto\s3.7.7\son\saccount\sof\sthe\snew\ssqlite3_vtab_config()\nand\ssqlite3_vtab_on_conflict()\sinterfaces.\s\sUpdates\sto\sthe\sdocumentation\son\nthose\sinterfaces. -D 2011-05-05T15:39:50.869 +C Fix\sa\sbug\sin\smemory\susage\stracking\sthat\swas\sintroduced\sby\ncheck-in\s[4e33a0eaf83922]. +D 2011-05-05T17:00:51.731 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 7a4d9524721d40ef9ee26f93f9bd6a51dba106f2 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -145,7 +145,7 @@ F src/legacy.c a199d7683d60cef73089e892409113e69c23a99f F src/lempar.c 7f026423f4d71d989e719a743f98a1cbd4e6d99e F src/loadext.c 3ae0d52da013a6326310655be6473fd472347b85 F src/main.c a8571665d43ff18f89a49d47a281605ce5ea825e -F src/malloc.c 74c740e8ba22b806cfb980c8c0ddea1cbd54a20e +F src/malloc.c 591aedb20ae40813f1045f2ef253438a334775d9 F src/mem0.c 6a55ebe57c46ca1a7d98da93aaa07f99f1059645 F src/mem1.c 00bd8265c81abb665c48fea1e0c234eb3b922206 F src/mem2.c e307323e86b5da1853d7111b68fd6b84ad6f09cf @@ -933,7 +933,7 @@ F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224 F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e F tool/split-sqlite3c.tcl d9be87f1c340285a3e081eb19b4a247981ed290c F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f -P 8485855afc71fb8078d53719c3da75021890ce9e -R d001197d2ada5bdc77fdb1803c900b72 +P 930be6a1bdec8c150caafd790973f7a401fc1970 +R 74676c63d123716a920c0fc74bf1b85a U drh -Z b6f82da815334ecd28dc3bea3383de2d +Z e5c86bfd12ceffed2348ff2cb6b52064 diff --git a/manifest.uuid b/manifest.uuid index a54682b9ba..351a91a73f 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -930be6a1bdec8c150caafd790973f7a401fc1970 \ No newline at end of file +8ba456ae0b3d0c0b6f72f98bd0bc28f72dfa4ff5 \ No newline at end of file diff --git a/src/malloc.c b/src/malloc.c index 3585f1245d..3e38d1df9f 100644 --- a/src/malloc.c +++ b/src/malloc.c @@ -533,7 +533,7 @@ void *sqlite3Realloc(void *pOld, int nBytes){ nDiff = nNew - nOld; if( sqlite3StatusValue(SQLITE_STATUS_MEMORY_USED) >= mem0.alarmThreshold-nDiff ){ - sqlite3MallocAlarm(nNew-nOld); + sqlite3MallocAlarm(nDiff); } assert( sqlite3MemdebugHasType(pOld, MEMTYPE_HEAP) ); assert( sqlite3MemdebugNoType(pOld, ~MEMTYPE_HEAP) ); @@ -544,7 +544,7 @@ void *sqlite3Realloc(void *pOld, int nBytes){ } if( pNew ){ nNew = sqlite3MallocSize(pNew); - sqlite3StatusAdd(SQLITE_STATUS_MEMORY_USED, nDiff); + sqlite3StatusAdd(SQLITE_STATUS_MEMORY_USED, nNew-nOld); } sqlite3_mutex_leave(mem0.mutex); }else{ From 87f67bf1436e3b48d52fcbeae57d00a6c62a886c Mon Sep 17 00:00:00 2001 From: drh Date: Thu, 5 May 2011 17:41:58 +0000 Subject: [PATCH 10/40] Fix sqlite3_vtab_on_conflict() to return the correct values for ABORT, FAIL, and IGNORE. FossilOrigin-Name: f0617d619dc6654f6d27543999c0aad724a0d967 --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/vtab.c | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/manifest b/manifest index 0226ba2e1c..e38d1ab9ba 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\sa\sbug\sin\smemory\susage\stracking\sthat\swas\sintroduced\sby\ncheck-in\s[4e33a0eaf83922]. -D 2011-05-05T17:00:51.731 +C Fix\ssqlite3_vtab_on_conflict()\sto\sreturn\sthe\scorrect\svalues\sfor\nABORT,\sFAIL,\sand\sIGNORE. +D 2011-05-05T17:41:58.205 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 7a4d9524721d40ef9ee26f93f9bd6a51dba106f2 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -244,7 +244,7 @@ F src/vdbeaux.c 25aa5ba7d46b4fe7c8f33dc132d474242d5f9726 F src/vdbeblob.c c3ccb7c8732858c680f442932e66ad06bb036562 F src/vdbemem.c 0498796b6ffbe45e32960d6a1f5adfb6e419883b F src/vdbetrace.c 5d0dc3d5fd54878cc8d6d28eb41deb8d5885b114 -F src/vtab.c 1491acb3e0a67eafe69134fb65bfa0b7b7e82342 +F src/vtab.c 5e17098829cb1533ae85aa46de98aa175f65eb83 F src/wal.c 7334009b396285b658a95a3b6bc6d2b016a1f794 F src/wal.h 7a5fbb00114b7f2cd40c7e1003d4c41ce9d26840 F src/walker.c 3112bb3afe1d85dc52317cb1d752055e9a781f8f @@ -933,7 +933,7 @@ F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224 F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e F tool/split-sqlite3c.tcl d9be87f1c340285a3e081eb19b4a247981ed290c F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f -P 930be6a1bdec8c150caafd790973f7a401fc1970 -R 74676c63d123716a920c0fc74bf1b85a +P 8ba456ae0b3d0c0b6f72f98bd0bc28f72dfa4ff5 +R e350890a304deaff131b57483c8e478b U drh -Z e5c86bfd12ceffed2348ff2cb6b52064 +Z 6b45c0a2e4c7eb15d8acfe532af4cf91 diff --git a/manifest.uuid b/manifest.uuid index 351a91a73f..89a83c1a8b 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -8ba456ae0b3d0c0b6f72f98bd0bc28f72dfa4ff5 \ No newline at end of file +f0617d619dc6654f6d27543999c0aad724a0d967 \ No newline at end of file diff --git a/src/vtab.c b/src/vtab.c index cac9c96064..ce48c932f9 100644 --- a/src/vtab.c +++ b/src/vtab.c @@ -1001,7 +1001,7 @@ void sqlite3VtabMakeWritable(Parse *pParse, Table *pTab){ */ int sqlite3_vtab_on_conflict(sqlite3 *db){ static const unsigned char aMap[] = { - SQLITE_ROLLBACK, SQLITE_IGNORE, SQLITE_ABORT, SQLITE_FAIL, SQLITE_REPLACE + SQLITE_ROLLBACK, SQLITE_ABORT, SQLITE_FAIL, SQLITE_IGNORE, SQLITE_REPLACE }; assert( OE_Rollback==1 && OE_Abort==2 && OE_Fail==3 ); assert( OE_Ignore==4 && OE_Replace==5 ); From 4d7a4461e23f15deb6e3879273faf9dd614757a2 Mon Sep 17 00:00:00 2001 From: dan Date: Thu, 5 May 2011 18:53:48 +0000 Subject: [PATCH 11/40] Have the xFullpath method in os_win.c discard the initial "/" if a filename begins with "/X:", where X is any alphabetic character. Also fix some test issues in uri.test. FossilOrigin-Name: fe57a8f621944fd2af5a4e9349c8fd77c4aba237 --- manifest | 14 ++++++------ manifest.uuid | 2 +- src/os_win.c | 7 ++++++ test/uri.test | 63 ++++++++++++++++++++++++++++++++++----------------- 4 files changed, 57 insertions(+), 29 deletions(-) diff --git a/manifest b/manifest index 32e0f8fc68..b62b84089c 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\sa\sproblem\sin\sthe\sURI\scode\spreventing\sthe\samalgamation\sfrom\sbuilding.\sAdd\scomments\sdescribing\sSQLITE_CONFIG_URI\sand\sSQLITE_OPEN_URI\sto\ssqlite.h.in. -D 2011-05-05T12:35:33.316 +C Have\sthe\sxFullpath\smethod\sin\sos_win.c\sdiscard\sthe\sinitial\s"/"\sif\sa\sfilename\sbegins\swith\s"/X:",\swhere\sX\sis\sany\salphabetic\scharacter.\sAlso\sfix\ssome\stest\sissues\sin\suri.test. +D 2011-05-05T18:53:48.721 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 7a4d9524721d40ef9ee26f93f9bd6a51dba106f2 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -164,7 +164,7 @@ F src/os.h 9dbed8c2b9c1f2f2ebabc09e49829d4777c26bf9 F src/os_common.h a8f95b81eca8a1ab8593d23e94f8a35f35d4078f F src/os_os2.c 4a75888ba3dfc820ad5e8177025972d74d7f2440 F src/os_unix.c 2c67d126874b78eb427371db4793f0e8fbc7448b -F src/os_win.c 4271f0bf733c0b45635ddcfb41c935573de8284c +F src/os_win.c ff0e14615a5086fa5ba6926e4ec0dc9cfb5a1a84 F src/pager.c 24b689bc3639d534f5fb292d2c68038b1e720527 F src/pager.h 3f8c783de1d4706b40b1ac15b64f5f896bcc78d1 F src/parse.y 12b7ebd61ea54f0e1b1083ff69cc2c8ce9353d58 @@ -840,7 +840,7 @@ F test/unique.test 083c7fff74695bcc27a71d75699deba3595bc9c2 F test/unixexcl.test 9d80a54d86d2261f660758928959368ffc36151e F test/unordered.test e81169ce2a8f31b2c6b66af691887e1376ab3ced F test/update.test 8bc86fd7ef1a00014f76dc6a6a7c974df4aef172 -F test/uri.test 858abdea53ac46844d52ba953fba78f15f0a463a +F test/uri.test f21a5cd025ccedf0c6d4c5e365bb47e163098c04 F test/utf16align.test 54cd35a27c005a9b6e7815d887718780b6a462ae F test/vacuum.test 29b60e8cc9e573b39676df6c4a75fe9e02d04a09 F test/vacuum2.test 91a84c9b08adfc4472097d2e8deb0150214e0e76 @@ -934,7 +934,7 @@ F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224 F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e F tool/split-sqlite3c.tcl d9be87f1c340285a3e081eb19b4a247981ed290c F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f -P af279f367e01732560b8b2b6aeb5ede4f04415dd -R b650932bbc0e364498f81d36888b653d +P ea562d6d67c2f2ef8baca02a77634c21b945196f +R ab4f619c8bbf9faf6cdcf553d75032d8 U dan -Z 505d1fe8270a91e9ebfb3524cd8d9a43 +Z d81fc059a3e07abc471a058222e61ec9 diff --git a/manifest.uuid b/manifest.uuid index 9a80005ad0..1014b9c417 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -ea562d6d67c2f2ef8baca02a77634c21b945196f \ No newline at end of file +fe57a8f621944fd2af5a4e9349c8fd77c4aba237 \ No newline at end of file diff --git a/src/os_win.c b/src/os_win.c index 4e91f7ab32..1300b90143 100644 --- a/src/os_win.c +++ b/src/os_win.c @@ -2465,6 +2465,13 @@ static int winFullPathname( void *zConverted; char *zOut; + /* If this path name begins with "/X:", where "X" is any alphabetic + ** character, discard the initial "/" from the pathname. + */ + if( zRelative[0]=='/' && sqlite3Isalpha(zRelative[1]) && zRelative[2]==':' ){ + zRelative++; + } + /* 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. This function could fail if, for example, the diff --git a/test/uri.test b/test/uri.test index 2da6574204..b8b83e8fd4 100644 --- a/test/uri.test +++ b/test/uri.test @@ -31,25 +31,31 @@ sqlite3_config_uri 1 # Test that file names are correctly extracted from URIs. # foreach {tn uri file} { - 1 test.db test.db - 2 file:test.db test.db - 3 file://PWD/test.db test.db - 4 file:PWD/test.db test.db - 5 file:test.db?mork=1 test.db - 6 file:test.db?mork=1&tonglor=2 test.db - 7 file:test.db?mork=1#boris test.db - 8 file:test.db#boris test.db - 9 test.db#boris test.db#boris - 10 test.db?mork=1#boris test.db?mork=1#boris - 11 file:test%2Edb test.db - 12 file file - 13 http:test.db http:test.db - 14 file://localhostPWD/test.db%3Fhello test.db?hello - 15 file:test.db%00extra test.db - 16 file:test%00.db%00extra test + 1 test.db test.db + 2 file:test.db test.db + 3 file://PWD/test.db test.db + 4 file:PWD/test.db test.db + 5 file:test.db?mork=1 test.db + 6 file:test.db?mork=1&tonglor=2 test.db + 7 file:test.db?mork=1#boris test.db + 8 file:test.db#boris test.db + 9 test.db#boris test.db#boris + 10 file:test%2Edb test.db + 11 file file + 12 http:test.db http:test.db + 13 file:test.db%00extra test.db + 14 file:test%00.db%00extra test + + 15 test.db?mork=1#boris test.db?mork=1#boris + 16 file://localhostPWD/test.db%3Fhello test.db?hello } { - set uri [string map [list PWD [pwd]] $uri] - set file [string map [list PWD [pwd]] $file] + + if {$tcl_platform(platform)=="windows"} { + if {$tn>14} break + set uri [string map [list PWD /[pwd]] $uri] + } else { + set uri [string map [list PWD [pwd]] $uri] + } forcedelete $file do_test 1.$tn.1 { file exists $file } 0 @@ -60,7 +66,7 @@ foreach {tn uri file} { do_test 1.$tn.3 { file exists $file } 0 sqlite3 db xxx.db - execsql { ATTACH $uri AS aux } + catchsql { ATTACH $uri AS aux } do_test 1.$tn.4 { file exists $file } 1 db close } @@ -69,6 +75,7 @@ foreach {tn uri file} { # Test that URI query parameters are passed through to the VFS layer # correctly. # +testvfs tvfs2 testvfs tvfs -default 1 tvfs filter xOpen tvfs script open_method @@ -79,7 +86,7 @@ foreach {tn uri kvlist} { 1 file:test.db?hello=world {hello world} 2 file:test.db?hello&world {hello {} world {}} 3 file:test.db?hello=1&world=2&vfs=tvfs {hello 1 world 2 vfs tvfs} - 4 file:test.db?hello=1&world=2&vfs=unix {} + 4 file:test.db?hello=1&world=2&vfs=tvfs2 {} 5 file:test.db?%68%65%6C%6C%6F=%77%6F%72%6C%64 {hello world} 6 file:test%00.db?hello%00extra=world%00ex {hello world} 7 file:test%00.db?hello%00=world%00 {hello world} @@ -88,9 +95,15 @@ foreach {tn uri kvlist} { 10 file:test.db?hello=%00world&xyz= {hello {} xyz {}} 11 file:test.db?=#ravada {} 12 file:test.db?&&&&&&&&hello=world&&&&&&& {hello world} + 13 test.db?&&&&&&&&hello=world&&&&&&& {} 14 http:test.db?hello&world {} } { + + if {$tcl_platform(platform) == "windows" && $tn>12} { + continue + } + set ::arglist "" set DB [sqlite3_open $uri] do_test 2.$tn.1 { set ::arglist } $kvlist @@ -103,6 +116,7 @@ foreach {tn uri kvlist} { db close } tvfs delete +tvfs2 delete #------------------------------------------------------------------------- # Test that specifying a non-existent VFS raises an error. @@ -217,6 +231,7 @@ proc tvfs2_callback {method filename args} { set ::T2([file tail $filename]) 1 } +catch {db close} eval forcedelete [glob test.db*] do_test 5.1.1 { sqlite3 db file:test.db1?vfs=tvfs1 @@ -254,7 +269,13 @@ foreach {tn uri res} { 5 "file://lbcalhost/PWD/test.db" {invalid uri authority: lbcalhost} 6 "file://x/PWD/test.db" {invalid uri authority: x} } { - set uri [string map [list PWD [string range [pwd] 1 end]] $uri] + + if {$tcl_platform(platform)=="windows"} { + set uri [string map [list PWD [string range [pwd] 3 end]] $uri] + } else { + set uri [string map [list PWD [string range [pwd] 1 end]] $uri] + } + do_test 6.$tn { set DB [sqlite3_open $uri] sqlite3_errmsg $DB From 33f5379c43802c6bb9df50087057ce2ae76f4ec2 Mon Sep 17 00:00:00 2001 From: dan Date: Thu, 5 May 2011 19:44:22 +0000 Subject: [PATCH 12/40] Changes to various test scripts so that they pass on windows. FossilOrigin-Name: 1586244b6d86d5a98af8c6f7a8324672e02df9c3 --- manifest | 31 +++++++------ manifest.uuid | 2 +- test/alter.test | 2 +- test/cast.test | 10 ++--- test/expr.test | 111 ++++++++++++++++++++++++---------------------- test/nan.test | 16 +++---- test/pager1.test | 5 ++- test/tester.tcl | 9 ++++ test/tkt3838.test | 2 +- test/tkt3922.test | 8 ++-- 10 files changed, 107 insertions(+), 89 deletions(-) diff --git a/manifest b/manifest index e38d1ab9ba..4a3dc78b27 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\ssqlite3_vtab_on_conflict()\sto\sreturn\sthe\scorrect\svalues\sfor\nABORT,\sFAIL,\sand\sIGNORE. -D 2011-05-05T17:41:58.205 +C Changes\sto\svarious\stest\sscripts\sso\sthat\sthey\spass\son\swindows. +D 2011-05-05T19:44:22.749 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 7a4d9524721d40ef9ee26f93f9bd6a51dba106f2 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -252,7 +252,7 @@ F src/where.c 55403ce19c506be6a321c7f129aff693d6103db5 F test/aggerror.test a867e273ef9e3d7919f03ef4f0e8c0d2767944f2 F test/alias.test 4529fbc152f190268a15f9384a5651bbbabc9d87 F test/all.test 51756962d522e474338e9b2ebb26e7364d4aa125 -F test/alter.test 4e47fb9ea59348b88fce4e8bb49de530128b104c +F test/alter.test a3f570072b53d7c0fe463bab3f5affa8e113c487 F test/alter2.test 75f731508f1bf27ba09a6075c66cd02216ba464b F test/alter3.test 8677e48d95536f7a6ed86a1a774744dadcc22b07 F test/alter4.test 1e5dd6b951e9f65ca66422edff02e56df82dd403 @@ -312,7 +312,7 @@ F test/capi3b.test efb2b9cfd127efa84433cd7a2d72ce0454ae0dc4 F test/capi3c.test bea67403a5e37a4b33230ee4723e315a2ffb31e7 F test/capi3d.test cd36571f014f34bdc4421967f6453cbb597d5d16 F test/capi3e.test f7408dda65c92b9056199fdc180f893015f83dde -F test/cast.test 166951664a0b0a2e0f8fb5997a152490c6363932 +F test/cast.test 4c275cbdc8202d6f9c54a3596701719868ac7dc3 F test/check.test db2b29d557544347d28e25b8406f5d5ecc3d1bc3 F test/coalesce.test cee0dccb9fbd2d494b77234bccf9dc6c6786eb91 F test/collate1.test e3eaa48c21e150814be1a7b852d2a8af24458d04 @@ -390,7 +390,7 @@ F test/exclusive.test 53e1841b422e554cecf0160f937c473d6d0e3062 F test/exclusive2.test 343d55130c12c67b8bf10407acec043a6c26c86b F test/exec.test e949714dc127eaa5ecc7d723efec1ec27118fdd7 F test/exists.test 5e2d64b4eb5a9d08876599bdae2e1213d2d12e2a -F test/expr.test 19e8ac40313e2282a47b586d11c4892040990d3a +F test/expr.test 67c9fd6f8f829e239dc8b0f4a08a73c08b09196d F test/fallocate.test 43dc34b8c24be6baffadc3b4401ee15710ce83c6 F test/filectrl.test 97003734290887566e01dded09dc9e99cb937e9e F test/filefmt.test f178cfc29501a14565954c961b226e61877dd32c @@ -591,7 +591,7 @@ F test/misuse.test 30b3a458e5a70c31e74c291937b6c82204c59f33 F test/multiplex.test a88f3e2c16e567e72be7296195c59fbdd6a8d3d4 F test/mutex1.test 78b2b9bb320e51d156c4efdb71b99b051e7a4b41 F test/mutex2.test bfeaeac2e73095b2ac32285d2756e3a65e681660 -F test/nan.test a44e04df1486fcfb02d32468cbcd3c8e1e433723 +F test/nan.test dc212a22b36109fd1ae37154292444ef249c5ec2 F test/notify1.test 8433bc74bd952fb8a6e3f8d7a4c2b28dfd69e310 F test/notify2.test 195a467e021f74197be2c4fb02d6dee644b8d8db F test/notify3.test d60923e186e0900f4812a845fcdfd8eea096e33a @@ -599,7 +599,7 @@ F test/notnull.test cc7c78340328e6112a13c3e311a9ab3127114347 F test/null.test a8b09b8ed87852742343b33441a9240022108993 F test/openv2.test af02ed0a9cbc0d2a61b8f35171d4d117e588e4ec F test/oserror.test 498d8337e9d15543eb7b004fef8594bf204ff43c -F test/pager1.test d8672fd0af5f4f9b99b06283d00f01547809bebe +F test/pager1.test 8baf4470b29511503abcaf1f17d16b16462e4d54 F test/pager2.test 745b911dde3d1f24ae0870bd433dfa83d7c658c1 F test/pager3.test 3856d9c80839be0668efee1b74811b1b7f7fc95f F test/pagerfault.test 9de4d3e0c59970b4c6cb8dac511fa242f335d8a7 @@ -689,7 +689,7 @@ F test/tclsqlite.test 8c154101e704170c2be10f137a5499ac2c6da8d3 F test/tempdb.test 19d0f66e2e3eeffd68661a11c83ba5e6ace9128c F test/temptable.test f42121a0d29a62f00f93274464164177ab1cc24a F test/temptrigger.test b0273db072ce5f37cf19140ceb1f0d524bbe9f05 -F test/tester.tcl d5139260aadd64f318ecbcf982316d5bbc254b1b +F test/tester.tcl a791ee74cb6b8f8613079ccc018bf2c8b952a26c F test/thread001.test a3e6a7254d1cb057836cb3145b60c10bf5b7e60f F test/thread002.test afd20095e6e845b405df4f2c920cb93301ca69db F test/thread003.test b824d4f52b870ae39fc5bae4d8070eca73085dca @@ -801,13 +801,13 @@ F test/tkt3793.test 754b73f0e6a9349c70dc57e522cf3247272ecd5d F test/tkt3810.test 90fa0635dfa7da9680c8cd3513350a49b3a8ae12 F test/tkt3824.test 150aa00bb6220672e5f0eb14dc8eaa36750425f0 F test/tkt3832.test 2300d10d57562b89875b72148338ac3e14f8847d -F test/tkt3838.test f956f0719b5f805b12dd1dbf19f19d298bacebc3 +F test/tkt3838.test d8490365a1c473d214f7878007e543410cbb715f F test/tkt3841.test 4659845bc53f809a5932c61c6ce8c5bb9d6b947f F test/tkt3871.test 43ecbc8d90dc83908e2a454aef345acc9d160c6f F test/tkt3879.test 2ad5bef2c87e9991ce941e054c31abe26ef7fb90 F test/tkt3911.test 74cd324f3ba653040cc6d94cc4857b290d12d633 F test/tkt3918.test e6cdf6bfcfe9ba939d86a4238a9dc55d6eec5d42 -F test/tkt3922.test 022ace32c049e3964f68492c12eb803e8e4856d8 +F test/tkt3922.test f26be40ab4fe6c00795629bd2006d96e270d9b1a F test/tkt3929.test 75a862e45bcb39e9a7944c89b92afa531304afca F test/tkt3935.test e15261fedb9e30a4305a311da614a5d8e693c767 F test/tkt3992.test f3e7d548ac26f763b47bc0f750da3d03c81071da @@ -933,7 +933,10 @@ F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224 F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e F tool/split-sqlite3c.tcl d9be87f1c340285a3e081eb19b4a247981ed290c F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f -P 8ba456ae0b3d0c0b6f72f98bd0bc28f72dfa4ff5 -R e350890a304deaff131b57483c8e478b -U drh -Z 6b45c0a2e4c7eb15d8acfe532af4cf91 +P f0617d619dc6654f6d27543999c0aad724a0d967 +R 70a14d63b609930237281c63ad04d09e +T *branch * win32-test-fixes +T *sym-win32-test-fixes * +T -sym-trunk * +U dan +Z d02b41e7d78bb6d169c1442486a8fed7 diff --git a/manifest.uuid b/manifest.uuid index 89a83c1a8b..530cb38e6f 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -f0617d619dc6654f6d27543999c0aad724a0d967 \ No newline at end of file +1586244b6d86d5a98af8c6f7a8324672e02df9c3 \ No newline at end of file diff --git a/test/alter.test b/test/alter.test index d4b72a6ae8..359034d5aa 100644 --- a/test/alter.test +++ b/test/alter.test @@ -650,7 +650,7 @@ do_test alter-6.7 { # Ticket #1665: Make sure ALTER TABLE ADD COLUMN works on a table # that includes a COLLATE clause. # -do_test alter-7.1 { +do_realnum_test alter-7.1 { execsql { CREATE TABLE t1(a TEXT COLLATE BINARY); ALTER TABLE t1 ADD COLUMN b INTEGER COLLATE NOCASE; diff --git a/test/cast.test b/test/cast.test index 7a239439b7..f47f4bb2bf 100644 --- a/test/cast.test +++ b/test/cast.test @@ -234,7 +234,7 @@ do_test cast-3.1 { do_test cast-3.2 { execsql {SELECT CAST(9223372036854774800 AS numeric)} } 9223372036854774800 -do_test cast-3.3 { +do_realnum_test cast-3.3 { execsql {SELECT CAST(9223372036854774800 AS real)} } 9.22337203685477e+18 do_test cast-3.4 { @@ -246,7 +246,7 @@ do_test cast-3.5 { do_test cast-3.6 { execsql {SELECT CAST(-9223372036854774800 AS numeric)} } -9223372036854774800 -do_test cast-3.7 { +do_realnum_test cast-3.7 { execsql {SELECT CAST(-9223372036854774800 AS real)} } -9.22337203685477e+18 do_test cast-3.8 { @@ -258,7 +258,7 @@ do_test cast-3.11 { do_test cast-3.12 { execsql {SELECT CAST('9223372036854774800' AS numeric)} } 9223372036854774800 -do_test cast-3.13 { +do_realnum_test cast-3.13 { execsql {SELECT CAST('9223372036854774800' AS real)} } 9.22337203685477e+18 ifcapable long_double { @@ -272,7 +272,7 @@ do_test cast-3.15 { do_test cast-3.16 { execsql {SELECT CAST('-9223372036854774800' AS numeric)} } -9223372036854774800 -do_test cast-3.17 { +do_realnum_test cast-3.17 { execsql {SELECT CAST('-9223372036854774800' AS real)} } -9.22337203685477e+18 ifcapable long_double { @@ -287,7 +287,7 @@ if {[db eval {PRAGMA encoding}]=="UTF-8"} { do_test cast-3.22 { execsql {SELECT CAST(x'39323233333732303336383534373734383030' AS numeric)} } 9223372036854774800 - do_test cast-3.23 { + do_realnum_test cast-3.23 { execsql {SELECT CAST(x'39323233333732303336383534373734383030' AS real)} } 9.22337203685477e+18 ifcapable long_double { diff --git a/test/expr.test b/test/expr.test index 5a3d167517..cc4c9c67f1 100644 --- a/test/expr.test +++ b/test/expr.test @@ -32,6 +32,11 @@ proc test_expr {name settings expr result} { execsql {BEGIN; UPDATE test1 SET %s; SELECT %s FROM test1; ROLLBACK;} } $settings $expr] $result } +proc test_realnum_expr {name settings expr result} { + do_realnum_test $name [format { + execsql {BEGIN; UPDATE test1 SET %s; SELECT %s FROM test1; ROLLBACK;} + } $settings $expr] $result +} test_expr expr-1.1 {i1=10, i2=20} {i1+i2} 30 test_expr expr-1.2 {i1=10, i2=20} {i1-i2} -10 @@ -164,7 +169,7 @@ ifcapable floatingpoint { } if {[working_64bit_int]} { - test_expr expr-1.106 {i1=0} {-9223372036854775808/-1} 9.22337203685478e+18 + test_realnum_expr expr-1.106 {i1=0} {-9223372036854775808/-1} 9.22337203685478e+18 } test_expr expr-1.107 {i1=0} {-9223372036854775808%-1} 0 @@ -203,100 +208,100 @@ test_expr expr-1.126 {i1=8, i2=8} \ ifcapable floatingpoint {if {[working_64bit_int]} { test_expr expr-1.200\ {i1=9223372036854775806, i2=1} {i1+i2} 9223372036854775807 - test_expr expr-1.201\ + test_realnum_expr expr-1.201\ {i1=9223372036854775806, i2=2} {i1+i2} 9.22337203685478e+18 - test_expr expr-1.202\ + test_realnum_expr expr-1.202\ {i1=9223372036854775806, i2=100000} {i1+i2} 9.22337203685488e+18 - test_expr expr-1.203\ + test_realnum_expr expr-1.203\ {i1=9223372036854775807, i2=0} {i1+i2} 9223372036854775807 - test_expr expr-1.204\ + test_realnum_expr expr-1.204\ {i1=9223372036854775807, i2=1} {i1+i2} 9.22337203685478e+18 - test_expr expr-1.205\ + test_realnum_expr expr-1.205\ {i2=9223372036854775806, i1=1} {i1+i2} 9223372036854775807 - test_expr expr-1.206\ + test_realnum_expr expr-1.206\ {i2=9223372036854775806, i1=2} {i1+i2} 9.22337203685478e+18 - test_expr expr-1.207\ + test_realnum_expr expr-1.207\ {i2=9223372036854775806, i1=100000} {i1+i2} 9.22337203685488e+18 - test_expr expr-1.208\ + test_realnum_expr expr-1.208\ {i2=9223372036854775807, i1=0} {i1+i2} 9223372036854775807 - test_expr expr-1.209\ + test_realnum_expr expr-1.209\ {i2=9223372036854775807, i1=1} {i1+i2} 9.22337203685478e+18 - test_expr expr-1.210\ + test_realnum_expr expr-1.210\ {i1=-9223372036854775807, i2=-1} {i1+i2} -9223372036854775808 - test_expr expr-1.211\ + test_realnum_expr expr-1.211\ {i1=-9223372036854775807, i2=-2} {i1+i2} -9.22337203685478e+18 - test_expr expr-1.212\ + test_realnum_expr expr-1.212\ {i1=-9223372036854775807, i2=-100000} {i1+i2} -9.22337203685488e+18 - test_expr expr-1.213\ + test_realnum_expr expr-1.213\ {i1=-9223372036854775808, i2=0} {i1+i2} -9223372036854775808 - test_expr expr-1.214\ + test_realnum_expr expr-1.214\ {i1=-9223372036854775808, i2=-1} {i1+i2} -9.22337203685478e+18 - test_expr expr-1.215\ + test_realnum_expr expr-1.215\ {i2=-9223372036854775807, i1=-1} {i1+i2} -9223372036854775808 - test_expr expr-1.216\ + test_realnum_expr expr-1.216\ {i2=-9223372036854775807, i1=-2} {i1+i2} -9.22337203685478e+18 - test_expr expr-1.217\ + test_realnum_expr expr-1.217\ {i2=-9223372036854775807, i1=-100000} {i1+i2} -9.22337203685488e+18 - test_expr expr-1.218\ + test_realnum_expr expr-1.218\ {i2=-9223372036854775808, i1=0} {i1+i2} -9223372036854775808 - test_expr expr-1.219\ + test_realnum_expr expr-1.219\ {i2=-9223372036854775808, i1=-1} {i1+i2} -9.22337203685478e+18 - test_expr expr-1.220\ + test_realnum_expr expr-1.220\ {i1=9223372036854775806, i2=-1} {i1-i2} 9223372036854775807 - test_expr expr-1.221\ + test_realnum_expr expr-1.221\ {i1=9223372036854775806, i2=-2} {i1-i2} 9.22337203685478e+18 - test_expr expr-1.222\ + test_realnum_expr expr-1.222\ {i1=9223372036854775806, i2=-100000} {i1-i2} 9.22337203685488e+18 - test_expr expr-1.223\ + test_realnum_expr expr-1.223\ {i1=9223372036854775807, i2=0} {i1-i2} 9223372036854775807 - test_expr expr-1.224\ + test_realnum_expr expr-1.224\ {i1=9223372036854775807, i2=-1} {i1-i2} 9.22337203685478e+18 - test_expr expr-1.225\ + test_realnum_expr expr-1.225\ {i2=-9223372036854775806, i1=1} {i1-i2} 9223372036854775807 - test_expr expr-1.226\ + test_realnum_expr expr-1.226\ {i2=-9223372036854775806, i1=2} {i1-i2} 9.22337203685478e+18 - test_expr expr-1.227\ + test_realnum_expr expr-1.227\ {i2=-9223372036854775806, i1=100000} {i1-i2} 9.22337203685488e+18 - test_expr expr-1.228\ + test_realnum_expr expr-1.228\ {i2=-9223372036854775807, i1=0} {i1-i2} 9223372036854775807 - test_expr expr-1.229\ + test_realnum_expr expr-1.229\ {i2=-9223372036854775807, i1=1} {i1-i2} 9.22337203685478e+18 - test_expr expr-1.230\ + test_realnum_expr expr-1.230\ {i1=-9223372036854775807, i2=1} {i1-i2} -9223372036854775808 - test_expr expr-1.231\ + test_realnum_expr expr-1.231\ {i1=-9223372036854775807, i2=2} {i1-i2} -9.22337203685478e+18 - test_expr expr-1.232\ + test_realnum_expr expr-1.232\ {i1=-9223372036854775807, i2=100000} {i1-i2} -9.22337203685488e+18 - test_expr expr-1.233\ + test_realnum_expr expr-1.233\ {i1=-9223372036854775808, i2=0} {i1-i2} -9223372036854775808 - test_expr expr-1.234\ + test_realnum_expr expr-1.234\ {i1=-9223372036854775808, i2=1} {i1-i2} -9.22337203685478e+18 - test_expr expr-1.235\ + test_realnum_expr expr-1.235\ {i2=9223372036854775807, i1=-1} {i1-i2} -9223372036854775808 - test_expr expr-1.236\ + test_realnum_expr expr-1.236\ {i2=9223372036854775807, i1=-2} {i1-i2} -9.22337203685478e+18 - test_expr expr-1.237\ + test_realnum_expr expr-1.237\ {i2=9223372036854775807, i1=-100000} {i1-i2} -9.22337203685488e+18 - test_expr expr-1.238\ + test_realnum_expr expr-1.238\ {i2=9223372036854775807, i1=0} {i1-i2} -9223372036854775807 - test_expr expr-1.239\ + test_realnum_expr expr-1.239\ {i2=9223372036854775807, i1=-1} {i1-i2} -9223372036854775808 - test_expr expr-1.250\ + test_realnum_expr expr-1.250\ {i1=4294967296, i2=2147483648} {i1*i2} 9.22337203685478e+18 - test_expr expr-1.251\ + test_realnum_expr expr-1.251\ {i1=4294967296, i2=2147483647} {i1*i2} 9223372032559808512 - test_expr expr-1.252\ + test_realnum_expr expr-1.252\ {i1=-4294967296, i2=2147483648} {i1*i2} -9223372036854775808 - test_expr expr-1.253\ + test_realnum_expr expr-1.253\ {i1=-4294967296, i2=2147483647} {i1*i2} -9223372032559808512 - test_expr expr-1.254\ + test_realnum_expr expr-1.254\ {i1=4294967296, i2=-2147483648} {i1*i2} -9223372036854775808 - test_expr expr-1.255\ + test_realnum_expr expr-1.255\ {i1=4294967296, i2=-2147483647} {i1*i2} -9223372032559808512 - test_expr expr-1.256\ + test_realnum_expr expr-1.256\ {i1=-4294967296, i2=-2147483648} {i1*i2} 9.22337203685478e+18 - test_expr expr-1.257\ + test_realnum_expr expr-1.257\ {i1=-4294967296, i2=-2147483647} {i1*i2} 9223372032559808512 }} @@ -883,7 +888,7 @@ do_test expr-12.2 { } {1 {near ")": syntax error}} ifcapable floatingpoint { - do_test expr-13.1 { + do_realnum_test expr-13.1 { execsql { SELECT 12345678901234567890; } @@ -908,12 +913,12 @@ if {[working_64bit_int]} { # If the value is too large, use String->Float conversion. # ifcapable floatingpoint { - do_test expr-13.4 { + do_realnum_test expr-13.4 { execsql { SELECT 0+'9223372036854775808' } } {9.22337203685478e+18} - do_test expr-13.5 { + do_realnum_test expr-13.5 { execsql { SELECT '9223372036854775808'+0 } @@ -923,12 +928,12 @@ ifcapable floatingpoint { # Use String->float conversion if the value is explicitly a floating # point value. # -do_test expr-13.6 { +do_realnum_test expr-13.6 { execsql { SELECT 0+'9223372036854775807.0' } } {9.22337203685478e+18} -do_test expr-13.7 { +do_realnum_test expr-13.7 { execsql { SELECT '9223372036854775807.0'+0 } diff --git a/test/nan.test b/test/nan.test index 0e9462fcb5..3257a439e4 100644 --- a/test/nan.test +++ b/test/nan.test @@ -42,31 +42,31 @@ do_test nan-1.1.1 { db eval {SELECT x, typeof(x) FROM t1} } {{} null} if {$tcl_platform(platform) != "symbian"} { - do_test nan-1.1.2 { + do_realnum_test nan-1.1.2 { sqlite3_bind_double $::STMT 1 +Inf sqlite3_step $::STMT sqlite3_reset $::STMT db eval {SELECT x, typeof(x) FROM t1} } {{} null inf real} - do_test nan-1.1.3 { + do_realnum_test nan-1.1.3 { sqlite3_bind_double $::STMT 1 -Inf sqlite3_step $::STMT sqlite3_reset $::STMT db eval {SELECT x, typeof(x) FROM t1} } {{} null inf real -inf real} - do_test nan-1.1.4 { + do_realnum_test nan-1.1.4 { sqlite3_bind_double $::STMT 1 -NaN sqlite3_step $::STMT sqlite3_reset $::STMT db eval {SELECT x, typeof(x) FROM t1} } {{} null inf real -inf real {} null} - do_test nan-1.1.5 { + do_realnum_test nan-1.1.5 { sqlite3_bind_double $::STMT 1 NaN0 sqlite3_step $::STMT sqlite3_reset $::STMT db eval {SELECT x, typeof(x) FROM t1} } {{} null inf real -inf real {} null {} null} - do_test nan-1.1.6 { + do_realnum_test nan-1.1.6 { sqlite3_bind_double $::STMT 1 -NaN0 sqlite3_step $::STMT sqlite3_reset $::STMT @@ -231,12 +231,12 @@ if {$tcl_platform(platform) != "symbian"} { # Do not run these tests on Symbian, as the Tcl port doesn't like to # convert from floating point value "-inf" to a string. # - do_test nan-4.7 { + do_realnum_test nan-4.7 { db eval {DELETE FROM t1} db eval "INSERT INTO t1 VALUES([string repeat 9 309].0)" db eval {SELECT x, typeof(x) FROM t1} } {inf real} - do_test nan-4.8 { + do_realnum_test nan-4.8 { db eval {DELETE FROM t1} db eval "INSERT INTO t1 VALUES(-[string repeat 9 309].0)" db eval {SELECT x, typeof(x) FROM t1} @@ -313,7 +313,7 @@ do_test nan-4.18 { db eval {SELECT CAST(x AS text), typeof(x) FROM t1} } {-9.88131291682493e-324 real} -do_test nan-4.20 { +do_realnum_test nan-4.20 { db eval {DELETE FROM t1} set big [string repeat 9 10000].0e-9000 db eval "INSERT INTO t1 VALUES($big)" diff --git a/test/pager1.test b/test/pager1.test index 8c31e1539c..fbdd4b20b9 100644 --- a/test/pager1.test +++ b/test/pager1.test @@ -1653,7 +1653,7 @@ for {set i 0} {$i<513} {incr i 3} { testvfs tv -default 1 tv script xOpenCb tv filter xOpen -proc xOpenCb {method filename} { +proc xOpenCb {method filename args} { set ::file_len [string length $filename] } sqlite3 db test.db @@ -2381,6 +2381,7 @@ do_test pager1-30.1 { # file can still be rolled back. This is required for backward compatibility - # versions of SQLite prior to 3.5.8 always set this field to zero. # +if {$tcl_platform(platform)=="unix"} { do_test pager1-31.1 { faultsim_delete_and_reopen execsql { @@ -2408,7 +2409,7 @@ do_test pager1-31.1 { sqlite3 db2 test.db2 execsql { PRAGMA integrity_check } db2 } {ok} - +} finish_test diff --git a/test/tester.tcl b/test/tester.tcl index 7e15ab07d6..0b66c3d788 100644 --- a/test/tester.tcl +++ b/test/tester.tcl @@ -354,6 +354,15 @@ proc do_test {name cmd expected} { flush stdout } +proc realnum_normalize {r} { + string map {1.#INF inf} [regsub -all {(e[+-])0+} $r {\1}] +} +proc do_realnum_test {name cmd expected} { + uplevel [list do_test $name [ + subst -nocommands { realnum_normalize [ $cmd ] } + ] [realnum_normalize $expected]] +} + proc fix_testname {varname} { upvar $varname testname if {[info exists ::testprefix] diff --git a/test/tkt3838.test b/test/tkt3838.test index 4fb5c55a8a..5dfc2b8afc 100644 --- a/test/tkt3838.test +++ b/test/tkt3838.test @@ -25,7 +25,7 @@ ifcapable !altertable { return } -do_test tkt3838-1.1 { +do_realnum_test tkt3838-1.1 { db eval { PRAGMA encoding=UTF16; CREATE TABLE t1(x); diff --git a/test/tkt3922.test b/test/tkt3922.test index 6506dcedb7..86bf5feceb 100644 --- a/test/tkt3922.test +++ b/test/tkt3922.test @@ -36,21 +36,21 @@ if {[working_64bit_int]} { } } {-1 integer} } -do_test tkt3922.2 { +do_realnum_test tkt3922.2 { execsql { DELETE FROM t1; INSERT INTO t1 VALUES('-9223372036854775809'); SELECT a, typeof(a) FROM t1; } } {-9.22337203685478e+18 real} -do_test tkt3922.3 { +do_realnum_test tkt3922.3 { execsql { DELETE FROM t1; INSERT INTO t1 VALUES('-9223372036854776832'); SELECT a, typeof(a) FROM t1; } } {-9.22337203685478e+18 real} -do_test tkt3922.4 { +do_realnum_test tkt3922.4 { execsql { DELETE FROM t1; INSERT INTO t1 VALUES('-9223372036854776833'); @@ -78,7 +78,7 @@ if {[working_64bit_int]} { } } {1 integer} } -do_test tkt3922.6 { +do_realnum_test tkt3922.6 { execsql { DELETE FROM t1; INSERT INTO t1 VALUES('9223372036854775808'); From 367e84d0899f1226d1201c5800e53060b672d9cc Mon Sep 17 00:00:00 2001 From: drh Date: Thu, 5 May 2011 23:07:43 +0000 Subject: [PATCH 13/40] Fix an incorrect assert() in sqlite3_value_config(). Updates to the sqlite3_value_config() documentation. FossilOrigin-Name: 22cbc01a2600c6100112315d9afb5f2d8f80b3df --- manifest | 14 ++++++------- manifest.uuid | 2 +- src/sqlite.h.in | 55 ++++++++++++++++++++++++------------------------- src/vtab.c | 2 +- 4 files changed, 36 insertions(+), 37 deletions(-) diff --git a/manifest b/manifest index e38d1ab9ba..990f957862 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\ssqlite3_vtab_on_conflict()\sto\sreturn\sthe\scorrect\svalues\sfor\nABORT,\sFAIL,\sand\sIGNORE. -D 2011-05-05T17:41:58.205 +C Fix\san\sincorrect\sassert()\sin\ssqlite3_value_config().\s\sUpdates\sto\sthe\nsqlite3_value_config()\sdocumentation. +D 2011-05-05T23:07:43.483 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 7a4d9524721d40ef9ee26f93f9bd6a51dba106f2 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -179,7 +179,7 @@ F src/resolve.c 1c0f32b64f8e3f555fe1f732f9d6f501a7f05706 F src/rowset.c 69afa95a97c524ba6faf3805e717b5b7ae85a697 F src/select.c d9d440809025a58547e39f4f268c2a296bfb56ff F src/shell.c 72e7e176bf46d5c6518d15ac4ad6847c4bb5df79 -F src/sqlite.h.in 9bf19a5dcf6317b0f091c255edaed0b1fc01dcd0 +F src/sqlite.h.in 7f5ec849936098c5932b43fea2b1c5a4e1ec87b7 F src/sqlite3ext.h c90bd5507099f62043832d73f6425d8d5c5da754 F src/sqliteInt.h e70a03bb66d209e279b3edeb57d4fdc42a1d9fda F src/sqliteLimit.h 164b0e6749d31e0daa1a4589a169d31c0dec7b3d @@ -244,7 +244,7 @@ F src/vdbeaux.c 25aa5ba7d46b4fe7c8f33dc132d474242d5f9726 F src/vdbeblob.c c3ccb7c8732858c680f442932e66ad06bb036562 F src/vdbemem.c 0498796b6ffbe45e32960d6a1f5adfb6e419883b F src/vdbetrace.c 5d0dc3d5fd54878cc8d6d28eb41deb8d5885b114 -F src/vtab.c 5e17098829cb1533ae85aa46de98aa175f65eb83 +F src/vtab.c bfd252c7d699ccb1287bea3e5ca49eac2222beb0 F src/wal.c 7334009b396285b658a95a3b6bc6d2b016a1f794 F src/wal.h 7a5fbb00114b7f2cd40c7e1003d4c41ce9d26840 F src/walker.c 3112bb3afe1d85dc52317cb1d752055e9a781f8f @@ -933,7 +933,7 @@ F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224 F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e F tool/split-sqlite3c.tcl d9be87f1c340285a3e081eb19b4a247981ed290c F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f -P 8ba456ae0b3d0c0b6f72f98bd0bc28f72dfa4ff5 -R e350890a304deaff131b57483c8e478b +P f0617d619dc6654f6d27543999c0aad724a0d967 +R 31cf9f23f5ca6aefc15da38ca5caec3a U drh -Z 6b45c0a2e4c7eb15d8acfe532af4cf91 +Z 536ce71311e8f997eb3d277fca3551df diff --git a/manifest.uuid b/manifest.uuid index 89a83c1a8b..c09f6aed82 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -f0617d619dc6654f6d27543999c0aad724a0d967 \ No newline at end of file +22cbc01a2600c6100112315d9afb5f2d8f80b3df \ No newline at end of file diff --git a/src/sqlite.h.in b/src/sqlite.h.in index 19b418b439..dfd794cf08 100644 --- a/src/sqlite.h.in +++ b/src/sqlite.h.in @@ -6425,37 +6425,36 @@ int sqlite3_vtab_config(sqlite3*, int op, ...); ** can use to customize and optimize their behavior. ** **
-**
SQLITE_VTAB_CONSTRAINT_SUPPORT -**
If the second argument to [sqlite3_vtab_config()] is -** SQLITE_VTAB_CONSTRAINT_SUPPORT, then SQLite expects this function to -** have been called with three arguments, the third of which being of -** type 'int'. If the third argument is zero, then the virtual table -** is indicating that it does not support constraints. In this case if -** a call to the [xUpdate] method returns [SQLITE_CONSTRAINT], the entire -** statement is rolled back as if [ON CONFLICT | OR ABORT] had been -** specified as part of the users SQL statement, regardless of the actual -** ON CONFLICT mode specified. +**
SQLITE_VTAB_CONSTRAINT_SUPPORT +**
Calls of the form +** [sqlite3_vtab_config](db,SQLITE_VTAB_CONSTRAINT_SUPPORT,X) are supported, +** where X is an integer. If X is zero, then the [virtual table] whose +** [xCreate] or [xConnect] method invoked [sqlite3_vtab_config()] does not +** support constraints. In this configuration (which is the default) if +** a call to the [xUpdate] method returns [SQLITE_CONSTRAINT], then the entire +** statement is rolled back as if [ON CONFLICT | OR ABORT] had been +** specified as part of the users SQL statement, regardless of the actual +** ON CONFLICT mode specified. ** -** If the third argument passed is non-zero, then the virtual table -** implementation must guarantee that if [xUpdate] returns -** [SQLITE_CONSTRAINT], it does so before any modifications to internal -** or persistent data structures have been made. If the [ON CONFLICT] -** mode is ABORT, FAIL, IGNORE or ROLLBACK, SQLite is able to roll back -** a statement or database transaction, and abandon or continue processing -** the current SQL statement as appropriate. If the ON CONFLICT mode is -** REPLACE and the [xUpdate] method returns [SQLITE_CONSTRAINT], SQLite -** handles this as if the ON CONFLICT mode had been ABORT. +** If X is non-zero, then the virtual table implementation guarantees +** that if [xUpdate] returns [SQLITE_CONSTRAINT], it will do so before +** any modifications to internal or persistent data structures have been made. +** If the [ON CONFLICT] mode is ABORT, FAIL, IGNORE or ROLLBACK, SQLite +** is able to roll back a statement or database transaction, and abandon +** or continue processing the current SQL statement as appropriate. +** If the ON CONFLICT mode is REPLACE and the [xUpdate] method returns +** [SQLITE_CONSTRAINT], SQLite handles this as if the ON CONFLICT mode +** had been ABORT. ** -** Virtual table implementations that are required to handle OR REPLACE -** must do so within the xUpdate method. If a call to the -** [sqlite3_vtab_on_conflict()] function indicates that the current ON -** CONFLICT policy is REPLACE, the virtual table implementation should -** silently replace the appropriate rows within the xUpdate callback and -** return SQLITE_OK. Or, if this is not possible, it may return -** SQLITE_CONSTRAINT, in which case SQLite falls back to OR ABORT -** constraint handling. +** Virtual table implementations that are required to handle OR REPLACE +** must do so within the [xUpdate] method. If a call to the +** [sqlite3_vtab_on_conflict()] function indicates that the current ON +** CONFLICT policy is REPLACE, the virtual table implementation should +** silently replace the appropriate rows within the xUpdate callback and +** return SQLITE_OK. Or, if this is not possible, it may return +** SQLITE_CONSTRAINT, in which case SQLite falls back to OR ABORT +** constraint handling. **
-** */ #define SQLITE_VTAB_CONSTRAINT_SUPPORT 1 diff --git a/src/vtab.c b/src/vtab.c index ce48c932f9..e7f7287da8 100644 --- a/src/vtab.c +++ b/src/vtab.c @@ -1027,7 +1027,7 @@ int sqlite3_vtab_config(sqlite3 *db, int op, ...){ if( !p ){ rc = SQLITE_MISUSE_BKPT; }else{ - assert( (p->pTab->tabFlags & TF_Virtual)!=0 ); + assert( p->pTab==0 || (p->pTab->tabFlags & TF_Virtual)!=0 ); p->pVTable->bConstraint = (u8)va_arg(ap, int); } break; From e578b5967ca7c85bb01aa00fa01afcd5d8ed0f3f Mon Sep 17 00:00:00 2001 From: drh Date: Fri, 6 May 2011 00:19:57 +0000 Subject: [PATCH 14/40] Increase the iVersion for sqlite3_module needed for the xSavepoint, xRelease, and xRollbackTo methods from 1 to 2. This is so that it will conform to published documentation. FossilOrigin-Name: 0f4954e9793332573d4ffa0c1e199180f4cb990a --- ext/fts3/fts3.c | 2 +- manifest | 16 ++++++++-------- manifest.uuid | 2 +- src/sqlite.h.in | 4 ++-- src/vtab.c | 2 +- 5 files changed, 13 insertions(+), 13 deletions(-) diff --git a/ext/fts3/fts3.c b/ext/fts3/fts3.c index 6794e3d67e..5a46983d55 100644 --- a/ext/fts3/fts3.c +++ b/ext/fts3/fts3.c @@ -3661,7 +3661,7 @@ static int fts3RollbackToMethod(sqlite3_vtab *pVtab, int iSavepoint){ } static const sqlite3_module fts3Module = { - /* iVersion */ 1, + /* iVersion */ 2, /* xCreate */ fts3CreateMethod, /* xConnect */ fts3ConnectMethod, /* xBestIndex */ fts3BestIndexMethod, diff --git a/manifest b/manifest index 990f957862..b1e07258d5 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\san\sincorrect\sassert()\sin\ssqlite3_value_config().\s\sUpdates\sto\sthe\nsqlite3_value_config()\sdocumentation. -D 2011-05-05T23:07:43.483 +C Increase\sthe\siVersion\sfor\ssqlite3_module\sneeded\sfor\sthe\sxSavepoint,\nxRelease,\sand\sxRollbackTo\smethods\sfrom\s1\sto\s2.\s\sThis\sis\sso\sthat\sit\swill\nconform\sto\spublished\sdocumentation. +D 2011-05-06T00:19:57.229 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 7a4d9524721d40ef9ee26f93f9bd6a51dba106f2 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -61,7 +61,7 @@ F ext/fts2/mkfts2amal.tcl 974d5d438cb3f7c4a652639262f82418c1e4cff0 F ext/fts3/README.syntax a19711dc5458c20734b8e485e75fb1981ec2427a F ext/fts3/README.tokenizers 998756696647400de63d5ba60e9655036cb966e9 F ext/fts3/README.txt 8c18f41574404623b76917b9da66fcb0ab38328d -F ext/fts3/fts3.c 73d6718dba1e4ef621ff8a4ac1c22019460c84cc +F ext/fts3/fts3.c 0077bd07395d2aabafa1ed1b104552619ecad34a F ext/fts3/fts3.h 3a10a0af180d502cecc50df77b1b22df142817fe F ext/fts3/fts3Int.h 8c2ac39ee17362571c58ab2c4f0667324c31f738 F ext/fts3/fts3_aux.c 9e931f55eed8498dafe7bc1160f10cbb1a652fdf @@ -179,7 +179,7 @@ F src/resolve.c 1c0f32b64f8e3f555fe1f732f9d6f501a7f05706 F src/rowset.c 69afa95a97c524ba6faf3805e717b5b7ae85a697 F src/select.c d9d440809025a58547e39f4f268c2a296bfb56ff F src/shell.c 72e7e176bf46d5c6518d15ac4ad6847c4bb5df79 -F src/sqlite.h.in 7f5ec849936098c5932b43fea2b1c5a4e1ec87b7 +F src/sqlite.h.in 7c70c29eb59e008b6aa46cdc2caf5e057c987496 F src/sqlite3ext.h c90bd5507099f62043832d73f6425d8d5c5da754 F src/sqliteInt.h e70a03bb66d209e279b3edeb57d4fdc42a1d9fda F src/sqliteLimit.h 164b0e6749d31e0daa1a4589a169d31c0dec7b3d @@ -244,7 +244,7 @@ F src/vdbeaux.c 25aa5ba7d46b4fe7c8f33dc132d474242d5f9726 F src/vdbeblob.c c3ccb7c8732858c680f442932e66ad06bb036562 F src/vdbemem.c 0498796b6ffbe45e32960d6a1f5adfb6e419883b F src/vdbetrace.c 5d0dc3d5fd54878cc8d6d28eb41deb8d5885b114 -F src/vtab.c bfd252c7d699ccb1287bea3e5ca49eac2222beb0 +F src/vtab.c 48dcef8bc757c2e7b488f68b5ddebb1650da2450 F src/wal.c 7334009b396285b658a95a3b6bc6d2b016a1f794 F src/wal.h 7a5fbb00114b7f2cd40c7e1003d4c41ce9d26840 F src/walker.c 3112bb3afe1d85dc52317cb1d752055e9a781f8f @@ -933,7 +933,7 @@ F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224 F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e F tool/split-sqlite3c.tcl d9be87f1c340285a3e081eb19b4a247981ed290c F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f -P f0617d619dc6654f6d27543999c0aad724a0d967 -R 31cf9f23f5ca6aefc15da38ca5caec3a +P 22cbc01a2600c6100112315d9afb5f2d8f80b3df +R ecae535d3c90fbfa52eb2d1910d430f2 U drh -Z 536ce71311e8f997eb3d277fca3551df +Z af2b86f0a254fd9cb92b70349edf3021 diff --git a/manifest.uuid b/manifest.uuid index c09f6aed82..59476c6ef8 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -22cbc01a2600c6100112315d9afb5f2d8f80b3df \ No newline at end of file +0f4954e9793332573d4ffa0c1e199180f4cb990a \ No newline at end of file diff --git a/src/sqlite.h.in b/src/sqlite.h.in index dfd794cf08..ad424dbbf0 100644 --- a/src/sqlite.h.in +++ b/src/sqlite.h.in @@ -4611,8 +4611,8 @@ struct sqlite3_module { void (**pxFunc)(sqlite3_context*,int,sqlite3_value**), void **ppArg); int (*xRename)(sqlite3_vtab *pVtab, const char *zNew); - /* The methods above are in version 0 of the sqlite_module object. Those - ** below are for version 1 and greater. */ + /* The methods above are in version 1 of the sqlite_module object. Those + ** below are for version 2 and greater. */ int (*xSavepoint)(sqlite3_vtab *pVTab, int); int (*xRelease)(sqlite3_vtab *pVTab, int); int (*xRollbackTo)(sqlite3_vtab *pVTab, int); diff --git a/src/vtab.c b/src/vtab.c index e7f7287da8..c64c897d07 100644 --- a/src/vtab.c +++ b/src/vtab.c @@ -874,7 +874,7 @@ int sqlite3VtabSavepoint(sqlite3 *db, int op, int iSavepoint){ int i; for(i=0; rc==SQLITE_OK && inVTrans; i++){ const sqlite3_module *pMod = db->aVTrans[i]->pMod->pModule; - if( pMod->iVersion>=1 ){ + if( pMod->iVersion>=2 ){ int (*xMethod)(sqlite3_vtab *, int); switch( op ){ case SAVEPOINT_BEGIN: From 286ab7c2b11cca77c83b68760a6c03d256e71b15 Mon Sep 17 00:00:00 2001 From: dan Date: Fri, 6 May 2011 18:34:54 +0000 Subject: [PATCH 15/40] Update comments and documentation associated with new URI parsing code. Add test file e_uri.test, containing tests mapped to documentation regarding URI filenames. FossilOrigin-Name: 92751788eae082e3104838cb6dd8b9793cb325d1 --- manifest | 19 ++- manifest.uuid | 2 +- src/main.c | 39 ++++- src/sqlite.h.in | 40 +++-- src/test1.c | 71 ++++++++ test/e_uri.test | 427 ++++++++++++++++++++++++++++++++++++++++++++++++ test/uri.test | 3 +- 7 files changed, 560 insertions(+), 41 deletions(-) create mode 100644 test/e_uri.test diff --git a/manifest b/manifest index b62b84089c..e5d13928ae 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Have\sthe\sxFullpath\smethod\sin\sos_win.c\sdiscard\sthe\sinitial\s"/"\sif\sa\sfilename\sbegins\swith\s"/X:",\swhere\sX\sis\sany\salphabetic\scharacter.\sAlso\sfix\ssome\stest\sissues\sin\suri.test. -D 2011-05-05T18:53:48.721 +C Update\scomments\sand\sdocumentation\sassociated\swith\snew\sURI\sparsing\scode.\sAdd\stest\sfile\se_uri.test,\scontaining\stests\smapped\sto\sdocumentation\sregarding\sURI\sfilenames. +D 2011-05-06T18:34:54.463 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 7a4d9524721d40ef9ee26f93f9bd6a51dba106f2 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -144,7 +144,7 @@ F src/journal.c 552839e54d1bf76fb8f7abe51868b66acacf6a0e F src/legacy.c a199d7683d60cef73089e892409113e69c23a99f F src/lempar.c 7f026423f4d71d989e719a743f98a1cbd4e6d99e F src/loadext.c 3ae0d52da013a6326310655be6473fd472347b85 -F src/main.c 872493d84fed9b9c910e1b7b2427a3e28dbe995a +F src/main.c 145f04d5d8a6a391093b8e6a3b37511ac79e05c3 F src/malloc.c 74c740e8ba22b806cfb980c8c0ddea1cbd54a20e F src/mem0.c 6a55ebe57c46ca1a7d98da93aaa07f99f1059645 F src/mem1.c 00bd8265c81abb665c48fea1e0c234eb3b922206 @@ -179,14 +179,14 @@ F src/resolve.c 1c0f32b64f8e3f555fe1f732f9d6f501a7f05706 F src/rowset.c 69afa95a97c524ba6faf3805e717b5b7ae85a697 F src/select.c d9d440809025a58547e39f4f268c2a296bfb56ff F src/shell.c 72e7e176bf46d5c6518d15ac4ad6847c4bb5df79 -F src/sqlite.h.in f865bde9a0af4cd77b85265df71a9d760e5def18 +F src/sqlite.h.in 6acf3863a9ac8cd613029ff4d477519406632d78 F src/sqlite3ext.h c90bd5507099f62043832d73f6425d8d5c5da754 F src/sqliteInt.h 5a7bf51f767fb67b484f09d73cccff683731af22 F src/sqliteLimit.h 164b0e6749d31e0daa1a4589a169d31c0dec7b3d F src/status.c 7ac64842c86cec2fc1a1d0e5c16d3beb8ad332bf F src/table.c 2cd62736f845d82200acfa1287e33feb3c15d62e F src/tclsqlite.c 501c9a200fd998a268be475be5858febc90b725b -F src/test1.c e0e4af306b678da05334c2ccaf0377ae8f06e911 +F src/test1.c f506164085bc4cbbb4b5c14b9c6de153f1aeafc5 F src/test2.c 80d323d11e909cf0eb1b6fbb4ac22276483bcf31 F src/test3.c 124ff9735fb6bb7d41de180d6bac90e7b1509432 F src/test4.c d1e5a5e904d4b444cf572391fdcb017638e36ff7 @@ -379,6 +379,7 @@ F test/e_resolve.test dcce9308fb13b934ce29591105d031d3e14fbba6 F test/e_select.test bf385ae3aa0f014c4933ae66fd3e1302138493eb F test/e_select2.test 5c3d3da19c7b3e90ae444579db2b70098599ab92 F test/e_update.test 963d6876064e65f318d1c93aaed36a02b9b389bf +F test/e_uri.test 26c3ba638e38b9a92272174564df41e7c48e25a1 F test/e_vacuum.test 6c09c2af7f2f140518f371c5342100118f779dcf F test/enc.test e54531cd6bf941ee6760be041dff19a104c7acea F test/enc2.test 6d91a5286f59add0cfcbb2d0da913b76f2242398 @@ -840,7 +841,7 @@ F test/unique.test 083c7fff74695bcc27a71d75699deba3595bc9c2 F test/unixexcl.test 9d80a54d86d2261f660758928959368ffc36151e F test/unordered.test e81169ce2a8f31b2c6b66af691887e1376ab3ced F test/update.test 8bc86fd7ef1a00014f76dc6a6a7c974df4aef172 -F test/uri.test f21a5cd025ccedf0c6d4c5e365bb47e163098c04 +F test/uri.test e8579b07985b8f4f658eb4e077962a9b2b7b6491 F test/utf16align.test 54cd35a27c005a9b6e7815d887718780b6a462ae F test/vacuum.test 29b60e8cc9e573b39676df6c4a75fe9e02d04a09 F test/vacuum2.test 91a84c9b08adfc4472097d2e8deb0150214e0e76 @@ -934,7 +935,7 @@ F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224 F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e F tool/split-sqlite3c.tcl d9be87f1c340285a3e081eb19b4a247981ed290c F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f -P ea562d6d67c2f2ef8baca02a77634c21b945196f -R ab4f619c8bbf9faf6cdcf553d75032d8 +P fe57a8f621944fd2af5a4e9349c8fd77c4aba237 +R 3f5b227194b2ccadbce712d322c27966 U dan -Z d81fc059a3e07abc471a058222e61ec9 +Z 5f09c493780289f14c0820ca02b5d7dc diff --git a/manifest.uuid b/manifest.uuid index 1014b9c417..4ea86418d5 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -fe57a8f621944fd2af5a4e9349c8fd77c4aba237 \ No newline at end of file +92751788eae082e3104838cb6dd8b9793cb325d1 \ No newline at end of file diff --git a/src/main.c b/src/main.c index 9021b8514b..bcfd2deb04 100644 --- a/src/main.c +++ b/src/main.c @@ -1791,9 +1791,28 @@ int sqlite3_limit(sqlite3 *db, int limitId, int newLimit){ } /* -** This function is used to parse URIs passed by the user to API functions -** sqlite3_open() or sqlite3_open_v2(), and for database URIs specified as -** part of ATTACH statements. +** This function is used to parse both URIs and non-URI filenames passed by the +** user to API functions sqlite3_open() or sqlite3_open_v2(), and for database +** URIs specified as part of ATTACH statements. +** +** The first argument to this function is the name of the VFS to use (or +** a NULL to signify the default VFS) if the URI does not contain a "vfs=xxx" +** query parameter. The second argument contains the URI (or non-URI filename) +** itself. When this function is called the *pFlags variable should contain +** the default flags to open the database handle with. The value stored in +** *pFlags may be updated before returning if the URI filename contains +** "cache=xxx" or "mode=xxx" query parameters. +** +** If successful, SQLITE_OK is returned. In this case *ppVfs is set to point to +** the VFS that should be used to open the database file. *pzFile is set to +** point to a buffer containing the name of the file to open. It is the +** responsibility of the caller to eventually call sqlite3_free() to release +** this buffer. +** +** If an error occurs, then an SQLite error code is returned and *pzErrMsg +** may be set to point to a buffer containing an English language error +** message. It is the responsibility of the caller to eventually release +** this buffer by calling sqlite3_free(). */ int sqlite3ParseUri( const char *zDefaultVfs, /* VFS to use if no "vfs=xxx" query option */ @@ -1819,8 +1838,12 @@ int sqlite3ParseUri( int iIn; /* Input character index */ int iOut = 0; /* Output character index */ int nByte = nUri+2; /* Bytes of space to allocate */ - for(iIn=0; iIn mode: ^(This option may be set to either "ro", "rw" or "rwc". -** Attempting to set it to any other value is an error)^. ^If "ro" is -** specified, then the database is opened for read-only access, just as if -** the [SQLITE_OPEN_READONLY] flag had been set in the third argument to -** sqlite3_prepare_v2(). ^If the mode option is set to "rw", then the -** database is opened for read-write (but not create) access, as if -** SQLITE_OPEN_READWRITE (but not SQLITE_OPEN_CREATE) had been set. -** ^Value "rwc" is equivalent to setting both SQLITE_OPEN_READWRITE and -** SQLITE_OPEN_CREATE. -** ^If sqlite3_open_v2() is used, it is an error to specify a value for -** the mode parameter that is less restrictive than that specified by the -** flags passed as the third parameter. +**
  • mode: ^(The mode parameter may be set to either "ro", "rw" or +** "rwc". Attempting to set it to any other value is an error)^. +** ^If "ro" is specified, then the database is opened for read-only +** access, just as if the [SQLITE_OPEN_READONLY] flag had been set in the +** third argument to sqlite3_prepare_v2(). ^If the mode option is set to +** "rw", then the database is opened for read-write (but not create) +** access, as if SQLITE_OPEN_READWRITE (but not SQLITE_OPEN_CREATE) had +** been set. ^Value "rwc" is equivalent to setting both +** SQLITE_OPEN_READWRITE and SQLITE_OPEN_CREATE. ^If sqlite3_open_v2() is +** used, it is an error to specify a value for the mode parameter that is +** less restrictive than that specified by the flags passed as the third +** parameter. ** **
  • cache: ^The cache parameter may be set to either "shared" or ** "private". ^Setting it to "shared" is equivalent to setting the @@ -2487,10 +2487,8 @@ void sqlite3_progress_handler(sqlite3*, int, int(*)(void*), void*); ** ** file:///C:/Documents%20and%20Settings/fred/Desktop/data.db ** Windows only: Open the file "data.db" on fred's desktop on drive -** C:. If the "C:/" component were omitted from this URI, then the -** file "\Documents and Settings\fred\Desktop\data.db" would be opened -** on the current drive. Note that the %20 escaping in this example -** is not strictly necessary - space characters can be used literally +** C:. Note that the %20 escaping in this example is not strictly +** necessary - space characters can be used literally ** in URI filenames. ** file:data.db?mode=ro&cache=private ** Open file "data.db" in the current directory for read-only access. diff --git a/src/test1.c b/src/test1.c index b79bbd0826..8e30123433 100644 --- a/src/test1.c +++ b/src/test1.c @@ -3845,6 +3845,76 @@ static int test_open( return TCL_OK; } +/* +** Usage: sqlite3_open_v2 FILENAME FLAGS VFS +*/ +static int test_open_v2( + void * clientData, + Tcl_Interp *interp, + int objc, + Tcl_Obj *CONST objv[] +){ + const char *zFilename; + const char *zVfs; + int flags = 0; + sqlite3 *db; + int rc; + char zBuf[100]; + + int nFlag; + Tcl_Obj **apFlag; + int i; + + if( objc!=4 ){ + Tcl_WrongNumArgs(interp, 1, objv, "FILENAME FLAGS VFS"); + return TCL_ERROR; + } + zFilename = Tcl_GetString(objv[1]); + zVfs = Tcl_GetString(objv[3]); + if( zVfs[0]==0x00 ) zVfs = 0; + + rc = Tcl_ListObjGetElements(interp, objv[2], &nFlag, &apFlag); + if( rc!=TCL_OK ) return rc; + for(i=0; i Date: Fri, 6 May 2011 18:53:27 +0000 Subject: [PATCH 16/40] Remove some unnecessary modifications from the uri branch. Add a test to show that ATTACH only interprets its argument as a URI if the connection was opened with SQLITE_OPEN_URI (or URI interpretation is globally enabled). FossilOrigin-Name: aa90b943254cf348aa2d23ac05e1895b188e2101 --- manifest | 20 ++++++++++---------- manifest.uuid | 2 +- src/date.c | 2 +- src/main.c | 5 +---- src/pragma.c | 10 +++++----- src/sqliteInt.h | 1 - test/e_uri.test | 35 ++++++++++++++++++++++++++++++++--- 7 files changed, 50 insertions(+), 25 deletions(-) diff --git a/manifest b/manifest index e5d13928ae..4b478aac3e 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Update\scomments\sand\sdocumentation\sassociated\swith\snew\sURI\sparsing\scode.\sAdd\stest\sfile\se_uri.test,\scontaining\stests\smapped\sto\sdocumentation\sregarding\sURI\sfilenames. -D 2011-05-06T18:34:54.463 +C Remove\ssome\sunnecessary\smodifications\sfrom\sthe\suri\sbranch.\sAdd\sa\stest\sto\sshow\sthat\sATTACH\sonly\sinterprets\sits\sargument\sas\sa\sURI\sif\sthe\sconnection\swas\sopened\swith\sSQLITE_OPEN_URI\s(or\sURI\sinterpretation\sis\sglobally\senabled). +D 2011-05-06T18:53:27.671 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 7a4d9524721d40ef9ee26f93f9bd6a51dba106f2 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -129,7 +129,7 @@ F src/build.c 0132bc6631fa617a1d28ef805921f6dbac18a514 F src/callback.c 0425c6320730e6d3981acfb9202c1bed9016ad1a F src/complete.c dc1d136c0feee03c2f7550bafc0d29075e36deac F src/ctime.c 7deec4534f3b5a0c3b4a4cbadf809d321f64f9c4 -F src/date.c 0d63575d484322aeb344224f6a11ab7c00373dd0 +F src/date.c 1548fdac51377e4e7833251de878b4058c148e1b F src/delete.c 7a24fcc9a31664d145acb97ce56b6d9f249a25e4 F src/expr.c e3cf0957c6b8faaaf7386a3bc69e53c0dc9705be F src/fault.c 160a0c015b6c2629d3899ed2daf63d75754a32bb @@ -144,7 +144,7 @@ F src/journal.c 552839e54d1bf76fb8f7abe51868b66acacf6a0e F src/legacy.c a199d7683d60cef73089e892409113e69c23a99f F src/lempar.c 7f026423f4d71d989e719a743f98a1cbd4e6d99e F src/loadext.c 3ae0d52da013a6326310655be6473fd472347b85 -F src/main.c 145f04d5d8a6a391093b8e6a3b37511ac79e05c3 +F src/main.c 2f46bf58a6092d19c25109135a385aed65ce81e1 F src/malloc.c 74c740e8ba22b806cfb980c8c0ddea1cbd54a20e F src/mem0.c 6a55ebe57c46ca1a7d98da93aaa07f99f1059645 F src/mem1.c 00bd8265c81abb665c48fea1e0c234eb3b922206 @@ -171,7 +171,7 @@ F src/parse.y 12b7ebd61ea54f0e1b1083ff69cc2c8ce9353d58 F src/pcache.c 09d38c44ab275db581f7a2f6ff8b9bc7f8c0faaa F src/pcache.h c683390d50f856d4cd8e24342ae62027d1bb6050 F src/pcache1.c d548e31beafa792d1994b663a29a5303569efc4e -F src/pragma.c 9e778decc3ee9bcaf88904b4a3b0a4360aaf0eab +F src/pragma.c 49c90ab27a4339d4b5bc0b03c08cbcf20ed8d454 F src/prepare.c e64261559a3187698a3e7e6c8b001a4f4f98dab4 F src/printf.c 585a36b6a963df832cfb69505afa3a34ed5ef8a1 F src/random.c cd4a67b3953b88019f8cd4ccd81394a8ddfaba50 @@ -181,7 +181,7 @@ F src/select.c d9d440809025a58547e39f4f268c2a296bfb56ff F src/shell.c 72e7e176bf46d5c6518d15ac4ad6847c4bb5df79 F src/sqlite.h.in 6acf3863a9ac8cd613029ff4d477519406632d78 F src/sqlite3ext.h c90bd5507099f62043832d73f6425d8d5c5da754 -F src/sqliteInt.h 5a7bf51f767fb67b484f09d73cccff683731af22 +F src/sqliteInt.h 88704cb43f5266981726c7aebe4fab15331fae9e F src/sqliteLimit.h 164b0e6749d31e0daa1a4589a169d31c0dec7b3d F src/status.c 7ac64842c86cec2fc1a1d0e5c16d3beb8ad332bf F src/table.c 2cd62736f845d82200acfa1287e33feb3c15d62e @@ -379,7 +379,7 @@ F test/e_resolve.test dcce9308fb13b934ce29591105d031d3e14fbba6 F test/e_select.test bf385ae3aa0f014c4933ae66fd3e1302138493eb F test/e_select2.test 5c3d3da19c7b3e90ae444579db2b70098599ab92 F test/e_update.test 963d6876064e65f318d1c93aaed36a02b9b389bf -F test/e_uri.test 26c3ba638e38b9a92272174564df41e7c48e25a1 +F test/e_uri.test dc9e8f06e44030904e6448c995386f325365713a F test/e_vacuum.test 6c09c2af7f2f140518f371c5342100118f779dcf F test/enc.test e54531cd6bf941ee6760be041dff19a104c7acea F test/enc2.test 6d91a5286f59add0cfcbb2d0da913b76f2242398 @@ -935,7 +935,7 @@ F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224 F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e F tool/split-sqlite3c.tcl d9be87f1c340285a3e081eb19b4a247981ed290c F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f -P fe57a8f621944fd2af5a4e9349c8fd77c4aba237 -R 3f5b227194b2ccadbce712d322c27966 +P 92751788eae082e3104838cb6dd8b9793cb325d1 +R 17771d4039dfb4d6c5c2179891343d50 U dan -Z 5f09c493780289f14c0820ca02b5d7dc +Z 3db264a024c67033897f2ea9d71b0326 diff --git a/manifest.uuid b/manifest.uuid index 4ea86418d5..e0b4872a14 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -92751788eae082e3104838cb6dd8b9793cb325d1 \ No newline at end of file +aa90b943254cf348aa2d23ac05e1895b188e2101 \ No newline at end of file diff --git a/src/date.c b/src/date.c index 5ee30c06df..b81049aa65 100644 --- a/src/date.c +++ b/src/date.c @@ -1039,7 +1039,7 @@ static void currentTimeFunc( UNUSED_PARAMETER(argv); db = sqlite3_context_db_handle(context); - sqlite3OsCurrentTimeInt64(db->pVfs &iT); + sqlite3OsCurrentTimeInt64(db->pVfs, &iT); t = iT/1000 - 10000*(sqlite3_int64)21086676; #ifdef HAVE_GMTIME_R { diff --git a/src/main.c b/src/main.c index bcfd2deb04..adaa6c662a 100644 --- a/src/main.c +++ b/src/main.c @@ -2056,10 +2056,7 @@ static int openDatabase( testcase( (1<<(flags&7))==0x02 ); /* READONLY */ testcase( (1<<(flags&7))==0x04 ); /* READWRITE */ testcase( (1<<(flags&7))==0x40 ); /* READWRITE | CREATE */ - if( ((1<<(flags&7)) & 0x46)==0 ){ - rc = SQLITE_MISUSE; - goto opendb_out; - } + if( ((1<<(flags&7)) & 0x46)==0 ) rc = SQLITE_MISUSE; if( sqlite3GlobalConfig.bCoreMutex==0 ){ isThreadsafe = 0; diff --git a/src/pragma.c b/src/pragma.c index 799805c40b..75ab26d441 100644 --- a/src/pragma.c +++ b/src/pragma.c @@ -49,7 +49,7 @@ static u8 getSafetyLevel(const char *z){ /* ** Interpret the given string as a boolean value. */ -u8 sqlite3GetBoolean(const char *z){ +static u8 getBoolean(const char *z){ return getSafetyLevel(z)&1; } @@ -219,7 +219,7 @@ static int flagPragma(Parse *pParse, const char *zLeft, const char *zRight){ mask &= ~(SQLITE_ForeignKeys); } - if( sqlite3GetBoolean(zRight) ){ + if( getBoolean(zRight) ){ db->flags |= mask; }else{ db->flags &= ~mask; @@ -433,7 +433,7 @@ void sqlite3Pragma( int b = -1; assert( pBt!=0 ); if( zRight ){ - b = sqlite3GetBoolean(zRight); + b = getBoolean(zRight); } if( pId2->n==0 && b>=0 ){ int ii; @@ -1033,7 +1033,7 @@ void sqlite3Pragma( #ifndef NDEBUG if( sqlite3StrICmp(zLeft, "parser_trace")==0 ){ if( zRight ){ - if( sqlite3GetBoolean(zRight) ){ + if( getBoolean(zRight) ){ sqlite3ParserTrace(stderr, "parser: "); }else{ sqlite3ParserTrace(0, 0); @@ -1047,7 +1047,7 @@ void sqlite3Pragma( */ if( sqlite3StrICmp(zLeft, "case_sensitive_like")==0 ){ if( zRight ){ - sqlite3RegisterLikeFunctions(db, sqlite3GetBoolean(zRight)); + sqlite3RegisterLikeFunctions(db, getBoolean(zRight)); } }else diff --git a/src/sqliteInt.h b/src/sqliteInt.h index 8e18b0f399..72a96a601b 100644 --- a/src/sqliteInt.h +++ b/src/sqliteInt.h @@ -2659,7 +2659,6 @@ void sqlite3ExprListDelete(sqlite3*, ExprList*); int sqlite3Init(sqlite3*, char**); int sqlite3InitCallback(void*, int, char**, char**); void sqlite3Pragma(Parse*,Token*,Token*,Token*,int); -u8 sqlite3GetBoolean(const char *z); void sqlite3ResetInternalSchema(sqlite3*, int); void sqlite3BeginParse(Parse*,int); void sqlite3CommitInternalChanges(sqlite3*); diff --git a/test/e_uri.test b/test/e_uri.test index 22bb49dd58..ab88be0555 100644 --- a/test/e_uri.test +++ b/test/e_uri.test @@ -65,29 +65,58 @@ if {$tcl_platform(platform) == "unix"} { set DB [sqlite3_open_v2 file:test.db [concat $flags SQLITE_OPEN_URI] ""] list [file exists file:test.db] [file exists test.db] } {0 1} - sqlite3_close $DB do_test 1.2 { + forcedelete file:test.db2 test.db2 + set STMT [sqlite3_prepare $DB "ATTACH 'file:test.db2' AS aux" -1 dummy] + sqlite3_step $STMT + sqlite3_finalize $STMT + list [file exists file:test.db2] [file exists test.db2] + } {0 1} + sqlite3_close $DB + do_test 1.3 { forcedelete file:test.db test.db set DB [sqlite3_open_v2 file:test.db [concat $flags] ""] list [file exists file:test.db] [file exists test.db] } {1 0} + do_test 1.4 { + forcedelete file:test.db2 test.db2 + set STMT [sqlite3_prepare $DB "ATTACH 'file:test.db2' AS aux" -1 dummy] + sqlite3_step $STMT + sqlite3_finalize $STMT + list [file exists file:test.db2] [file exists test.db2] + } {1 0} sqlite3_close $DB # Tests with SQLITE_CONFIG_URI configured to true. URI intepretation is # enabled with or without SQLITE_OPEN_URI. + # sqlite3_shutdown sqlite3_config_uri 1 - do_test 1.3 { + do_test 1.5 { forcedelete file:test.db test.db set DB [sqlite3_open_v2 file:test.db [concat $flags SQLITE_OPEN_URI] ""] list [file exists file:test.db] [file exists test.db] } {0 1} + do_test 1.6 { + forcedelete file:test.db2 test.db2 + set STMT [sqlite3_prepare $DB "ATTACH 'file:test.db2' AS aux" -1 dummy] + sqlite3_step $STMT + sqlite3_finalize $STMT + list [file exists file:test.db2] [file exists test.db2] + } {0 1} sqlite3_close $DB - do_test 1.4 { + do_test 1.7 { forcedelete file:test.db test.db set DB [sqlite3_open_v2 file:test.db [concat $flags] ""] list [file exists file:test.db] [file exists test.db] } {0 1} + do_test 1.8 { + forcedelete file:test.db2 test.db2 + set STMT [sqlite3_prepare $DB "ATTACH 'file:test.db2' AS aux" -1 dummy] + sqlite3_step $STMT + sqlite3_finalize $STMT + list [file exists file:test.db2] [file exists test.db2] + } {0 1} sqlite3_close $DB } From 522c26fbfb5fd44e9f62c5f43dd26274d670554c Mon Sep 17 00:00:00 2001 From: drh Date: Sat, 7 May 2011 14:40:29 +0000 Subject: [PATCH 17/40] Fix minor compiler warnings. FossilOrigin-Name: 139eecbe1b072711a36128f1eeb24fc3e3bacc1c --- manifest | 18 +++++++++--------- manifest.uuid | 2 +- src/attach.c | 2 +- src/main.c | 10 +++++----- src/sqliteInt.h | 5 +++-- 5 files changed, 19 insertions(+), 18 deletions(-) diff --git a/manifest b/manifest index 5407a84c2f..882e6dc356 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Merge\sthe\suri\sbranch\swith\sthe\strunk. -D 2011-05-06T18:55:31.561 +C Fix\sminor\scompiler\swarnings. +D 2011-05-07T14:40:29.349 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 7a4d9524721d40ef9ee26f93f9bd6a51dba106f2 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -117,7 +117,7 @@ F sqlite3.1 6be1ad09113570e1fc8dcaff84c9b0b337db5ffc F sqlite3.pc.in ae6f59a76e862f5c561eb32a380228a02afc3cad F src/alter.c 280f5c04b11b492703a342222b3de0a999445280 F src/analyze.c a425d62e8fa9ebcb4359ab84ff0c62c6563d2e2a -F src/attach.c 79f8e5d286a2873e78d2068f35c4d6270572728f +F src/attach.c 77caa25fb9d16a030438674f16b77844078d18ed F src/auth.c 523da7fb4979469955d822ff9298352d6b31de34 F src/backup.c 986c15232757f2873dff35ee3b35cbf935fc573c F src/bitvec.c af50f1c8c0ff54d6bdb7a80e2fceca5a93670bef @@ -144,7 +144,7 @@ F src/journal.c 552839e54d1bf76fb8f7abe51868b66acacf6a0e F src/legacy.c a199d7683d60cef73089e892409113e69c23a99f F src/lempar.c 7f026423f4d71d989e719a743f98a1cbd4e6d99e F src/loadext.c 3ae0d52da013a6326310655be6473fd472347b85 -F src/main.c 2f46bf58a6092d19c25109135a385aed65ce81e1 +F src/main.c 35bce9d0c201d35f8398716c04be7fb616c600b3 F src/malloc.c 591aedb20ae40813f1045f2ef253438a334775d9 F src/mem0.c 6a55ebe57c46ca1a7d98da93aaa07f99f1059645 F src/mem1.c 00bd8265c81abb665c48fea1e0c234eb3b922206 @@ -181,7 +181,7 @@ F src/select.c d9d440809025a58547e39f4f268c2a296bfb56ff F src/shell.c 72e7e176bf46d5c6518d15ac4ad6847c4bb5df79 F src/sqlite.h.in 41a0e4bc842917226e170273f64b95717a63270a F src/sqlite3ext.h c90bd5507099f62043832d73f6425d8d5c5da754 -F src/sqliteInt.h 88704cb43f5266981726c7aebe4fab15331fae9e +F src/sqliteInt.h b34bd64a7ade4808fcc301e0bb67ef5051ea49c6 F src/sqliteLimit.h 164b0e6749d31e0daa1a4589a169d31c0dec7b3d F src/status.c 7ac64842c86cec2fc1a1d0e5c16d3beb8ad332bf F src/table.c 2cd62736f845d82200acfa1287e33feb3c15d62e @@ -935,7 +935,7 @@ F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224 F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e F tool/split-sqlite3c.tcl d9be87f1c340285a3e081eb19b4a247981ed290c F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f -P 2e5c0ed724060388b97e0c0881bb1b68ec1a23b4 aa90b943254cf348aa2d23ac05e1895b188e2101 -R c22e979da3dd966376ac72fa0b40e97e -U dan -Z b712e33d0a07bca3b809872e2e7a1ec4 +P 88df33c45fd5875ea82bc757b239fe3e61663c12 +R 60bd58714af3d9085d800460facedd20 +U drh +Z 41f26c68b9bef2dce351bff5509fd9e2 diff --git a/manifest.uuid b/manifest.uuid index c42c56cef9..e005b5342c 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -88df33c45fd5875ea82bc757b239fe3e61663c12 \ No newline at end of file +139eecbe1b072711a36128f1eeb24fc3e3bacc1c \ No newline at end of file diff --git a/src/attach.c b/src/attach.c index 7c546a5c1b..7e6f7c1fbb 100644 --- a/src/attach.c +++ b/src/attach.c @@ -72,7 +72,7 @@ static void attachFunc( const char *zFile; char *zPath = 0; char *zErr = 0; - int flags; + unsigned int flags; Db *aNew; char *zErrDyn = 0; sqlite3_vfs *pVfs; diff --git a/src/main.c b/src/main.c index adaa6c662a..1515d7d2ac 100644 --- a/src/main.c +++ b/src/main.c @@ -1817,13 +1817,13 @@ int sqlite3_limit(sqlite3 *db, int limitId, int newLimit){ int sqlite3ParseUri( const char *zDefaultVfs, /* VFS to use if no "vfs=xxx" query option */ const char *zUri, /* Nul-terminated URI to parse */ - int *pFlags, /* IN/OUT: SQLITE_OPEN_XXX flags */ + unsigned int *pFlags, /* IN/OUT: SQLITE_OPEN_XXX flags */ sqlite3_vfs **ppVfs, /* OUT: VFS to use */ char **pzFile, /* OUT: Filename component of URI */ char **pzErrMsg /* OUT: Error message (if rc!=SQLITE_OK) */ ){ int rc = SQLITE_OK; - int flags = *pFlags; + unsigned int flags = *pFlags; const char *zVfs = zDefaultVfs; char *zFile; int nUri = sqlite3Strlen30(zUri); @@ -1972,7 +1972,7 @@ int sqlite3ParseUri( int mode = 0; for(i=0; aMode[i].z; i++){ const char *z = aMode[i].z; - if( nVal==strlen(z) && 0==memcmp(zVal, z, nVal) ){ + if( nVal==sqlite3Strlen30(z) && 0==memcmp(zVal, z, nVal) ){ mode = aMode[i].mode; break; } @@ -2025,7 +2025,7 @@ int sqlite3ParseUri( static int openDatabase( const char *zFilename, /* Database filename UTF-8 encoded */ sqlite3 **ppDb, /* OUT: Returned database handle */ - unsigned flags, /* Operational flags */ + unsigned int flags, /* Operational flags */ const char *zVfs /* Name of the VFS to use */ ){ sqlite3 *db; /* Store allocated handle here */ @@ -2294,7 +2294,7 @@ int sqlite3_open_v2( int flags, /* Flags */ const char *zVfs /* Name of VFS module to use */ ){ - return openDatabase(filename, ppDb, flags, zVfs); + return openDatabase(filename, ppDb, (unsigned int)flags, zVfs); } #ifndef SQLITE_OMIT_UTF16 diff --git a/src/sqliteInt.h b/src/sqliteInt.h index 72a96a601b..4a3e45d7c0 100644 --- a/src/sqliteInt.h +++ b/src/sqliteInt.h @@ -803,7 +803,7 @@ struct sqlite3 { int nDb; /* Number of backends currently in use */ Db *aDb; /* All backends */ int flags; /* Miscellaneous flags. See below */ - int openFlags; /* Flags passed to sqlite3_vfs.xOpen() */ + unsigned int openFlags; /* Flags passed to sqlite3_vfs.xOpen() */ int errCode; /* Most recent error code (SQLITE_*) */ int errMask; /* & result codes with this before returning */ u8 autoCommit; /* The auto-commit flag. */ @@ -2673,7 +2673,8 @@ void sqlite3AddColumnType(Parse*,Token*); void sqlite3AddDefaultValue(Parse*,ExprSpan*); void sqlite3AddCollateType(Parse*, Token*); void sqlite3EndTable(Parse*,Token*,Token*,Select*); -int sqlite3ParseUri(const char*,const char*,int*,sqlite3_vfs**,char**,char **); +int sqlite3ParseUri(const char*,const char*,unsigned int*, + sqlite3_vfs**,char**,char **); Bitvec *sqlite3BitvecCreate(u32); int sqlite3BitvecTest(Bitvec*, u32); From 5dd72ad6df8040a8799c0b6ec483f3d1d6f0099a Mon Sep 17 00:00:00 2001 From: drh Date: Sat, 7 May 2011 18:18:33 +0000 Subject: [PATCH 18/40] Return SQLITE_MISUSE from the sqlite3_open_v2() function if the 3rd parameter is not a valid set of bit-values. FossilOrigin-Name: 3c926ce0976e765b4c51fcd81d251268ff21a741 --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/main.c | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/manifest b/manifest index 882e6dc356..43a2d8df59 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\sminor\scompiler\swarnings. -D 2011-05-07T14:40:29.349 +C Return\sSQLITE_MISUSE\sfrom\sthe\ssqlite3_open_v2()\sfunction\sif\sthe\s3rd\sparameter\nis\snot\sa\svalid\sset\sof\sbit-values. +D 2011-05-07T18:18:33.871 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 7a4d9524721d40ef9ee26f93f9bd6a51dba106f2 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -144,7 +144,7 @@ F src/journal.c 552839e54d1bf76fb8f7abe51868b66acacf6a0e F src/legacy.c a199d7683d60cef73089e892409113e69c23a99f F src/lempar.c 7f026423f4d71d989e719a743f98a1cbd4e6d99e F src/loadext.c 3ae0d52da013a6326310655be6473fd472347b85 -F src/main.c 35bce9d0c201d35f8398716c04be7fb616c600b3 +F src/main.c 9c9cfeb1e2dad0485e55bfb2d647cf7e6bcfc0d9 F src/malloc.c 591aedb20ae40813f1045f2ef253438a334775d9 F src/mem0.c 6a55ebe57c46ca1a7d98da93aaa07f99f1059645 F src/mem1.c 00bd8265c81abb665c48fea1e0c234eb3b922206 @@ -935,7 +935,7 @@ F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224 F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e F tool/split-sqlite3c.tcl d9be87f1c340285a3e081eb19b4a247981ed290c F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f -P 88df33c45fd5875ea82bc757b239fe3e61663c12 -R 60bd58714af3d9085d800460facedd20 +P 139eecbe1b072711a36128f1eeb24fc3e3bacc1c +R 9647e2f243248962e973055679cb35ec U drh -Z 41f26c68b9bef2dce351bff5509fd9e2 +Z b72c527dc0866038aace0b0ad58a6fe8 diff --git a/manifest.uuid b/manifest.uuid index e005b5342c..da38fe3379 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -139eecbe1b072711a36128f1eeb24fc3e3bacc1c \ No newline at end of file +3c926ce0976e765b4c51fcd81d251268ff21a741 \ No newline at end of file diff --git a/src/main.c b/src/main.c index 1515d7d2ac..f941a9398b 100644 --- a/src/main.c +++ b/src/main.c @@ -2056,7 +2056,7 @@ static int openDatabase( testcase( (1<<(flags&7))==0x02 ); /* READONLY */ testcase( (1<<(flags&7))==0x04 ); /* READWRITE */ testcase( (1<<(flags&7))==0x40 ); /* READWRITE | CREATE */ - if( ((1<<(flags&7)) & 0x46)==0 ) rc = SQLITE_MISUSE; + if( ((1<<(flags&7)) & 0x46)==0 ) return SQLITE_MISUSE_BKPT; if( sqlite3GlobalConfig.bCoreMutex==0 ){ isThreadsafe = 0; From ffd9668fb5c64a542ed8a54598e8e347bc12d963 Mon Sep 17 00:00:00 2001 From: drh Date: Sat, 7 May 2011 18:40:36 +0000 Subject: [PATCH 19/40] Set the sqlite3.mallocFailed flag if sqlite3ParseUri fails with SQLITE_NOMEM. FossilOrigin-Name: ca3797d4967361e31a8a5ce1ce8190b095f3ed4c --- manifest | 14 +++++++------- manifest.uuid | 2 +- src/attach.c | 1 + src/main.c | 1 + 4 files changed, 10 insertions(+), 8 deletions(-) diff --git a/manifest b/manifest index 43a2d8df59..27e92dc7ff 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Return\sSQLITE_MISUSE\sfrom\sthe\ssqlite3_open_v2()\sfunction\sif\sthe\s3rd\sparameter\nis\snot\sa\svalid\sset\sof\sbit-values. -D 2011-05-07T18:18:33.871 +C Set\sthe\ssqlite3.mallocFailed\sflag\sif\ssqlite3ParseUri\sfails\swith\sSQLITE_NOMEM. +D 2011-05-07T18:40:36.334 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 7a4d9524721d40ef9ee26f93f9bd6a51dba106f2 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -117,7 +117,7 @@ F sqlite3.1 6be1ad09113570e1fc8dcaff84c9b0b337db5ffc F sqlite3.pc.in ae6f59a76e862f5c561eb32a380228a02afc3cad F src/alter.c 280f5c04b11b492703a342222b3de0a999445280 F src/analyze.c a425d62e8fa9ebcb4359ab84ff0c62c6563d2e2a -F src/attach.c 77caa25fb9d16a030438674f16b77844078d18ed +F src/attach.c 12c6957996908edc31c96d7c68d4942c2474405f F src/auth.c 523da7fb4979469955d822ff9298352d6b31de34 F src/backup.c 986c15232757f2873dff35ee3b35cbf935fc573c F src/bitvec.c af50f1c8c0ff54d6bdb7a80e2fceca5a93670bef @@ -144,7 +144,7 @@ F src/journal.c 552839e54d1bf76fb8f7abe51868b66acacf6a0e F src/legacy.c a199d7683d60cef73089e892409113e69c23a99f F src/lempar.c 7f026423f4d71d989e719a743f98a1cbd4e6d99e F src/loadext.c 3ae0d52da013a6326310655be6473fd472347b85 -F src/main.c 9c9cfeb1e2dad0485e55bfb2d647cf7e6bcfc0d9 +F src/main.c c914afd2c37b7662acb5034c20465b807037b84c F src/malloc.c 591aedb20ae40813f1045f2ef253438a334775d9 F src/mem0.c 6a55ebe57c46ca1a7d98da93aaa07f99f1059645 F src/mem1.c 00bd8265c81abb665c48fea1e0c234eb3b922206 @@ -935,7 +935,7 @@ F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224 F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e F tool/split-sqlite3c.tcl d9be87f1c340285a3e081eb19b4a247981ed290c F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f -P 139eecbe1b072711a36128f1eeb24fc3e3bacc1c -R 9647e2f243248962e973055679cb35ec +P 3c926ce0976e765b4c51fcd81d251268ff21a741 +R 469c4635a93084885b543f0cd5b2c5df U drh -Z b72c527dc0866038aace0b0ad58a6fe8 +Z c02f1d6b5c75b5c7abb8e8e853d0d67b diff --git a/manifest.uuid b/manifest.uuid index da38fe3379..60e4538975 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -3c926ce0976e765b4c51fcd81d251268ff21a741 \ No newline at end of file +ca3797d4967361e31a8a5ce1ce8190b095f3ed4c \ No newline at end of file diff --git a/src/attach.c b/src/attach.c index 7e6f7c1fbb..18f8823b31 100644 --- a/src/attach.c +++ b/src/attach.c @@ -131,6 +131,7 @@ static void attachFunc( flags = db->openFlags; rc = sqlite3ParseUri(db->pVfs->zName, zFile, &flags, &pVfs, &zPath, &zErr); if( rc!=SQLITE_OK ){ + if( rc==SQLITE_NOMEM ) db->mallocFailed = 1; sqlite3_result_error(context, zErr, -1); sqlite3_free(zErr); return; diff --git a/src/main.c b/src/main.c index f941a9398b..6fdffcd876 100644 --- a/src/main.c +++ b/src/main.c @@ -2162,6 +2162,7 @@ static int openDatabase( /* Parse the filename/URI argument. */ rc = sqlite3ParseUri(zVfs, zFilename, &flags, &db->pVfs, &zOpen, &zErrMsg); if( rc!=SQLITE_OK ){ + if( rc==SQLITE_NOMEM ) db->mallocFailed = 1; sqlite3Error(db, rc, zErrMsg ? "%s" : 0, zErrMsg); sqlite3_free(zErrMsg); goto opendb_out; From de941c3756aeafd202276c5f8028958717c0b5e4 Mon Sep 17 00:00:00 2001 From: drh Date: Mon, 9 May 2011 19:20:17 +0000 Subject: [PATCH 20/40] Return a suitable error message if the mode= argument to a URI specifies a higher mode than what is allowed by context. Other minor cleanups for the URI parsing logic. FossilOrigin-Name: d9bc1c7fe0ca5f6973a85827330958f4d09f8171 --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/main.c | 15 +++++++++------ 3 files changed, 16 insertions(+), 13 deletions(-) diff --git a/manifest b/manifest index 27e92dc7ff..daee9754e7 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Set\sthe\ssqlite3.mallocFailed\sflag\sif\ssqlite3ParseUri\sfails\swith\sSQLITE_NOMEM. -D 2011-05-07T18:40:36.334 +C Return\sa\ssuitable\serror\smessage\sif\sthe\smode=\sargument\sto\sa\sURI\sspecifies\na\shigher\smode\sthan\swhat\sis\sallowed\sby\scontext.\s\sOther\sminor\scleanups\sfor\nthe\sURI\sparsing\slogic. +D 2011-05-09T19:20:17.775 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 7a4d9524721d40ef9ee26f93f9bd6a51dba106f2 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -144,7 +144,7 @@ F src/journal.c 552839e54d1bf76fb8f7abe51868b66acacf6a0e F src/legacy.c a199d7683d60cef73089e892409113e69c23a99f F src/lempar.c 7f026423f4d71d989e719a743f98a1cbd4e6d99e F src/loadext.c 3ae0d52da013a6326310655be6473fd472347b85 -F src/main.c c914afd2c37b7662acb5034c20465b807037b84c +F src/main.c f00cee5a27f5df5ed536e7043cb451b3c85ce65c F src/malloc.c 591aedb20ae40813f1045f2ef253438a334775d9 F src/mem0.c 6a55ebe57c46ca1a7d98da93aaa07f99f1059645 F src/mem1.c 00bd8265c81abb665c48fea1e0c234eb3b922206 @@ -935,7 +935,7 @@ F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224 F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e F tool/split-sqlite3c.tcl d9be87f1c340285a3e081eb19b4a247981ed290c F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f -P 3c926ce0976e765b4c51fcd81d251268ff21a741 -R 469c4635a93084885b543f0cd5b2c5df +P ca3797d4967361e31a8a5ce1ce8190b095f3ed4c +R fbfaa47316ae48b91e92f26cbe2f2742 U drh -Z c02f1d6b5c75b5c7abb8e8e853d0d67b +Z 82e3dc394cc5052bfb9a5a6a21e4f298 diff --git a/manifest.uuid b/manifest.uuid index 60e4538975..2b8787f1e2 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -ca3797d4967361e31a8a5ce1ce8190b095f3ed4c \ No newline at end of file +d9bc1c7fe0ca5f6973a85827330958f4d09f8171 \ No newline at end of file diff --git a/src/main.c b/src/main.c index 6fdffcd876..5b46f4b736 100644 --- a/src/main.c +++ b/src/main.c @@ -1826,6 +1826,7 @@ int sqlite3ParseUri( unsigned int flags = *pFlags; const char *zVfs = zDefaultVfs; char *zFile; + char c; int nUri = sqlite3Strlen30(zUri); assert( *pzErrMsg==0 ); @@ -1873,8 +1874,8 @@ int sqlite3ParseUri( ** 2: Parsing value section of a name=value query parameter. */ eState = 0; - while( zUri[iIn] && zUri[iIn]!='#' ){ - char c = zUri[iIn++]; + while( (c = zUri[iIn])!=0 && c!='#' ){ + iIn++; if( c=='%' && sqlite3Isxdigit(zUri[iIn]) && sqlite3Isxdigit(zUri[iIn+1]) @@ -1888,10 +1889,10 @@ int sqlite3ParseUri( ** case we ignore all text in the remainder of the path, name or ** value currently being parsed. So ignore the current character ** and skip to the next "?", "=" or "&", as appropriate. */ - while( zUri[iIn] && zUri[iIn]!='#' - && (eState!=0 || zUri[iIn]!='?') - && (eState!=1 || (zUri[iIn]!='=' && zUri[iIn]!='&')) - && (eState!=2 || zUri[iIn]!='&') + while( (c = zUri[iIn])!=0 && c!='#' + && (eState!=0 || c!='?') + && (eState!=1 || (c!='=' && c!='&')) + && (eState!=2 || c!='&') ){ iIn++; } @@ -1983,6 +1984,8 @@ int sqlite3ParseUri( goto parse_uri_out; } if( mode>limit ){ + *pzErrMsg = sqlite3_mprintf("%s mode not allowed: %s", + zModeType, zVal); rc = SQLITE_PERM; goto parse_uri_out; } From e9d45e347e21fde1449c471ef81bfb9b7054ab4a Mon Sep 17 00:00:00 2001 From: drh Date: Tue, 10 May 2011 10:17:02 +0000 Subject: [PATCH 21/40] Add new documentation keywords to the sqlite3_vfs description. FossilOrigin-Name: ad3389a9ab07f6b811841ffa76a5292719c4487d --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/sqlite.h.in | 1 + 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/manifest b/manifest index daee9754e7..2418251fb3 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Return\sa\ssuitable\serror\smessage\sif\sthe\smode=\sargument\sto\sa\sURI\sspecifies\na\shigher\smode\sthan\swhat\sis\sallowed\sby\scontext.\s\sOther\sminor\scleanups\sfor\nthe\sURI\sparsing\slogic. -D 2011-05-09T19:20:17.775 +C Add\snew\sdocumentation\skeywords\sto\sthe\ssqlite3_vfs\sdescription. +D 2011-05-10T10:17:02.660 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 7a4d9524721d40ef9ee26f93f9bd6a51dba106f2 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -179,7 +179,7 @@ F src/resolve.c 1c0f32b64f8e3f555fe1f732f9d6f501a7f05706 F src/rowset.c 69afa95a97c524ba6faf3805e717b5b7ae85a697 F src/select.c d9d440809025a58547e39f4f268c2a296bfb56ff F src/shell.c 72e7e176bf46d5c6518d15ac4ad6847c4bb5df79 -F src/sqlite.h.in 41a0e4bc842917226e170273f64b95717a63270a +F src/sqlite.h.in 6e1af9733864bacbb4b5b821290f5395319f3259 F src/sqlite3ext.h c90bd5507099f62043832d73f6425d8d5c5da754 F src/sqliteInt.h b34bd64a7ade4808fcc301e0bb67ef5051ea49c6 F src/sqliteLimit.h 164b0e6749d31e0daa1a4589a169d31c0dec7b3d @@ -935,7 +935,7 @@ F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224 F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e F tool/split-sqlite3c.tcl d9be87f1c340285a3e081eb19b4a247981ed290c F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f -P ca3797d4967361e31a8a5ce1ce8190b095f3ed4c -R fbfaa47316ae48b91e92f26cbe2f2742 +P d9bc1c7fe0ca5f6973a85827330958f4d09f8171 +R a4c51c77960c2b3e78f68dee95566335 U drh -Z 82e3dc394cc5052bfb9a5a6a21e4f298 +Z 5d4e7081fc9730bf21891a9cc297b17d diff --git a/manifest.uuid b/manifest.uuid index 2b8787f1e2..7523acf4d5 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -d9bc1c7fe0ca5f6973a85827330958f4d09f8171 \ No newline at end of file +ad3389a9ab07f6b811841ffa76a5292719c4487d \ No newline at end of file diff --git a/src/sqlite.h.in b/src/sqlite.h.in index d78daa7672..c83d0d70d4 100644 --- a/src/sqlite.h.in +++ b/src/sqlite.h.in @@ -758,6 +758,7 @@ typedef struct sqlite3_mutex sqlite3_mutex; /* ** CAPI3REF: OS Interface Object +** KEYWORDS: VFS VFSes ** ** An instance of the sqlite3_vfs object defines the interface between ** the SQLite core and the underlying operating system. The "vfs" From eaadd59ab0240ba445dd6aebc58426a0e8143bf3 Mon Sep 17 00:00:00 2001 From: dan Date: Tue, 10 May 2011 17:43:28 +0000 Subject: [PATCH 22/40] Update URI test cases to account for the new error message format. FossilOrigin-Name: 5bde568028216f5bbf76fa0b61bf5b736699f4b1 --- manifest | 16 ++++++++-------- manifest.uuid | 2 +- test/e_uri.test | 6 +++--- test/uri.test | 2 +- 4 files changed, 13 insertions(+), 13 deletions(-) diff --git a/manifest b/manifest index 2418251fb3..c4d5b41728 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Add\snew\sdocumentation\skeywords\sto\sthe\ssqlite3_vfs\sdescription. -D 2011-05-10T10:17:02.660 +C Update\sURI\stest\scases\sto\saccount\sfor\sthe\snew\serror\smessage\sformat. +D 2011-05-10T17:43:28.367 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 7a4d9524721d40ef9ee26f93f9bd6a51dba106f2 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -379,7 +379,7 @@ F test/e_resolve.test dcce9308fb13b934ce29591105d031d3e14fbba6 F test/e_select.test bf385ae3aa0f014c4933ae66fd3e1302138493eb F test/e_select2.test 5c3d3da19c7b3e90ae444579db2b70098599ab92 F test/e_update.test 963d6876064e65f318d1c93aaed36a02b9b389bf -F test/e_uri.test dc9e8f06e44030904e6448c995386f325365713a +F test/e_uri.test 9ce11319fb9b271bf7392027f913f7830e93e7a7 F test/e_vacuum.test 6c09c2af7f2f140518f371c5342100118f779dcf F test/enc.test e54531cd6bf941ee6760be041dff19a104c7acea F test/enc2.test 6d91a5286f59add0cfcbb2d0da913b76f2242398 @@ -841,7 +841,7 @@ F test/unique.test 083c7fff74695bcc27a71d75699deba3595bc9c2 F test/unixexcl.test 9d80a54d86d2261f660758928959368ffc36151e F test/unordered.test e81169ce2a8f31b2c6b66af691887e1376ab3ced F test/update.test 8bc86fd7ef1a00014f76dc6a6a7c974df4aef172 -F test/uri.test e8579b07985b8f4f658eb4e077962a9b2b7b6491 +F test/uri.test 19d64e06602a1d000f0fc0ffd39b3a204fb3ad19 F test/utf16align.test 54cd35a27c005a9b6e7815d887718780b6a462ae F test/vacuum.test 29b60e8cc9e573b39676df6c4a75fe9e02d04a09 F test/vacuum2.test 91a84c9b08adfc4472097d2e8deb0150214e0e76 @@ -935,7 +935,7 @@ F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224 F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e F tool/split-sqlite3c.tcl d9be87f1c340285a3e081eb19b4a247981ed290c F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f -P d9bc1c7fe0ca5f6973a85827330958f4d09f8171 -R a4c51c77960c2b3e78f68dee95566335 -U drh -Z 5d4e7081fc9730bf21891a9cc297b17d +P ad3389a9ab07f6b811841ffa76a5292719c4487d +R a45bf605351a6737b616ae7b167a1c39 +U dan +Z 08251c747d7ddaeeaf3c4b5510848f0d diff --git a/manifest.uuid b/manifest.uuid index 7523acf4d5..f305bc8bff 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -ad3389a9ab07f6b811841ffa76a5292719c4487d \ No newline at end of file +5bde568028216f5bbf76fa0b61bf5b736699f4b1 \ No newline at end of file diff --git a/test/e_uri.test b/test/e_uri.test index ab88be0555..b0e2f876de 100644 --- a/test/e_uri.test +++ b/test/e_uri.test @@ -319,12 +319,12 @@ foreach {tn uri flags error} { 2 {file:test.db?mode=ro} rw {not an error} 3 {file:test.db?mode=ro} rwc {not an error} - 4 {file:test.db?mode=rw} ro {access permission denied} + 4 {file:test.db?mode=rw} ro {access mode not allowed: rw} 5 {file:test.db?mode=rw} rw {not an error} 6 {file:test.db?mode=rw} rwc {not an error} - 7 {file:test.db?mode=rwc} ro {access permission denied} - 8 {file:test.db?mode=rwc} rw {access permission denied} + 7 {file:test.db?mode=rwc} ro {access mode not allowed: rwc} + 8 {file:test.db?mode=rwc} rw {access mode not allowed: rwc} 9 {file:test.db?mode=rwc} rwc {not an error} } { set f(ro) [list SQLITE_OPEN_READONLY SQLITE_OPEN_URI] diff --git a/test/uri.test b/test/uri.test index 22e0fc9bde..08f20c2595 100644 --- a/test/uri.test +++ b/test/uri.test @@ -157,7 +157,7 @@ foreach {tn mode create_ok write_ok readonly_ok} { } $A($write_ok) set A(1) {0 {}} - set A(0) {1 {access permission denied}} + set A(0) [list 1 "access mode not allowed: $mode"] do_test 4.1.$tn.3 { list [catch {sqlite3 db "file:test.db?mode=$mode" -readonly 1} msg] $msg } $A($readonly_ok) From 194329962919e3b0f2cd764bfa3300ddbcafcad0 Mon Sep 17 00:00:00 2001 From: dan Date: Tue, 10 May 2011 18:39:10 +0000 Subject: [PATCH 23/40] Have flags passed to sqlite3_open_v2() apply to the main and any attached databases. And change things so that any "mode=xxx" or "cache=xxx" options specified as part of a URI for the main database do not also apply to attached databases. FossilOrigin-Name: 3e490915301216e242a5cdeb0febaff12ed53cb9 --- manifest | 14 +++++++------- manifest.uuid | 2 +- src/main.c | 2 +- test/uri.test | 25 ++++++++++++++++++++++++- 4 files changed, 33 insertions(+), 10 deletions(-) diff --git a/manifest b/manifest index c4d5b41728..aa9682ca60 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Update\sURI\stest\scases\sto\saccount\sfor\sthe\snew\serror\smessage\sformat. -D 2011-05-10T17:43:28.367 +C Have\sflags\spassed\sto\ssqlite3_open_v2()\sapply\sto\sthe\smain\sand\sany\sattached\sdatabases.\sAnd\schange\sthings\sso\sthat\sany\s"mode=xxx"\sor\s"cache=xxx"\soptions\sspecified\sas\spart\sof\sa\sURI\sfor\sthe\smain\sdatabase\sdo\snot\salso\sapply\sto\sattached\sdatabases. +D 2011-05-10T18:39:10.068 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 7a4d9524721d40ef9ee26f93f9bd6a51dba106f2 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -144,7 +144,7 @@ F src/journal.c 552839e54d1bf76fb8f7abe51868b66acacf6a0e F src/legacy.c a199d7683d60cef73089e892409113e69c23a99f F src/lempar.c 7f026423f4d71d989e719a743f98a1cbd4e6d99e F src/loadext.c 3ae0d52da013a6326310655be6473fd472347b85 -F src/main.c f00cee5a27f5df5ed536e7043cb451b3c85ce65c +F src/main.c e32d7a44c3307a4a33cfd1a2b06fb46f418ba7fc F src/malloc.c 591aedb20ae40813f1045f2ef253438a334775d9 F src/mem0.c 6a55ebe57c46ca1a7d98da93aaa07f99f1059645 F src/mem1.c 00bd8265c81abb665c48fea1e0c234eb3b922206 @@ -841,7 +841,7 @@ F test/unique.test 083c7fff74695bcc27a71d75699deba3595bc9c2 F test/unixexcl.test 9d80a54d86d2261f660758928959368ffc36151e F test/unordered.test e81169ce2a8f31b2c6b66af691887e1376ab3ced F test/update.test 8bc86fd7ef1a00014f76dc6a6a7c974df4aef172 -F test/uri.test 19d64e06602a1d000f0fc0ffd39b3a204fb3ad19 +F test/uri.test 2d08a6f77bf93ca925743a65802c4aa23aaaf373 F test/utf16align.test 54cd35a27c005a9b6e7815d887718780b6a462ae F test/vacuum.test 29b60e8cc9e573b39676df6c4a75fe9e02d04a09 F test/vacuum2.test 91a84c9b08adfc4472097d2e8deb0150214e0e76 @@ -935,7 +935,7 @@ F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224 F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e F tool/split-sqlite3c.tcl d9be87f1c340285a3e081eb19b4a247981ed290c F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f -P ad3389a9ab07f6b811841ffa76a5292719c4487d -R a45bf605351a6737b616ae7b167a1c39 +P 5bde568028216f5bbf76fa0b61bf5b736699f4b1 +R 109bc7e0fff78b0c6554d3e5815c2cd8 U dan -Z 08251c747d7ddaeeaf3c4b5510848f0d +Z 5955a7caf010dc14908da2de85096565 diff --git a/manifest.uuid b/manifest.uuid index f305bc8bff..2b5e8e05a9 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -5bde568028216f5bbf76fa0b61bf5b736699f4b1 \ No newline at end of file +3e490915301216e242a5cdeb0febaff12ed53cb9 \ No newline at end of file diff --git a/src/main.c b/src/main.c index 5b46f4b736..d19f5f9012 100644 --- a/src/main.c +++ b/src/main.c @@ -2163,6 +2163,7 @@ static int openDatabase( nocaseCollatingFunc, 0); /* Parse the filename/URI argument. */ + db->openFlags = flags; rc = sqlite3ParseUri(zVfs, zFilename, &flags, &db->pVfs, &zOpen, &zErrMsg); if( rc!=SQLITE_OK ){ if( rc==SQLITE_NOMEM ) db->mallocFailed = 1; @@ -2172,7 +2173,6 @@ static int openDatabase( } /* Open the backend database driver */ - db->openFlags = flags; rc = sqlite3BtreeOpen(db->pVfs, zOpen, db, &db->aDb[0].pBt, 0, flags | SQLITE_OPEN_MAIN_DB); if( rc!=SQLITE_OK ){ diff --git a/test/uri.test b/test/uri.test index 08f20c2595..42cbc66d77 100644 --- a/test/uri.test +++ b/test/uri.test @@ -21,6 +21,7 @@ source $testdir/tester.tcl # 4.*: Tests for specifying other options (other than "vfs"). # 5.*: Test using a different VFS with an attached database. # 6.*: Test that authorities other than "" and localhost cause errors. +# 7.*: Test that a read-write db can be attached to a read-only connection. # set testprefix uri @@ -282,5 +283,27 @@ foreach {tn uri res} { catch { sqlite3_close $DB } } -finish_test +forcedelete test.db test.db2 +do_test 7.1 { + sqlite3 db test.db + execsql { + CREATE TABLE t1(a, b); + INSERT INTO t1 VALUES(1, 2); + ATTACH 'test.db2' AS aux; + CREATE TABLE aux.t2(a, b); + INSERT INTO t1 VALUES('a', 'b'); + } + db close +} {} +do_test 7.2 { + sqlite3 db file:test.db?mode=ro + execsql { ATTACH 'file:test.db2?mode=rw' AS aux } +} {} +do_execsql_test 7.3 { + INSERT INTO t2 VALUES('c', 'd') +} {} +do_catchsql_test 7.4 { + INSERT INTO t1 VALUES(3, 4) +} {1 {attempt to write a readonly database}} +finish_test From 55fc08f154f4e3aaecf09618bd5235f8859e226f Mon Sep 17 00:00:00 2001 From: drh Date: Wed, 11 May 2011 19:00:10 +0000 Subject: [PATCH 24/40] URI filename documentation updates. FossilOrigin-Name: 8885c8677b239d4cbef24b9409a1736e1ae97a3f --- manifest | 14 +++++++------- manifest.uuid | 2 +- src/sqlite.h.in | 44 +++++++++++++++++++++++++++----------------- 3 files changed, 35 insertions(+), 25 deletions(-) diff --git a/manifest b/manifest index aa9682ca60..4d23d290be 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Have\sflags\spassed\sto\ssqlite3_open_v2()\sapply\sto\sthe\smain\sand\sany\sattached\sdatabases.\sAnd\schange\sthings\sso\sthat\sany\s"mode=xxx"\sor\s"cache=xxx"\soptions\sspecified\sas\spart\sof\sa\sURI\sfor\sthe\smain\sdatabase\sdo\snot\salso\sapply\sto\sattached\sdatabases. -D 2011-05-10T18:39:10.068 +C URI\sfilename\sdocumentation\supdates. +D 2011-05-11T19:00:10.252 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 7a4d9524721d40ef9ee26f93f9bd6a51dba106f2 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -179,7 +179,7 @@ F src/resolve.c 1c0f32b64f8e3f555fe1f732f9d6f501a7f05706 F src/rowset.c 69afa95a97c524ba6faf3805e717b5b7ae85a697 F src/select.c d9d440809025a58547e39f4f268c2a296bfb56ff F src/shell.c 72e7e176bf46d5c6518d15ac4ad6847c4bb5df79 -F src/sqlite.h.in 6e1af9733864bacbb4b5b821290f5395319f3259 +F src/sqlite.h.in 901b70703bb444d2c13b085e2cd2258b6a707e94 F src/sqlite3ext.h c90bd5507099f62043832d73f6425d8d5c5da754 F src/sqliteInt.h b34bd64a7ade4808fcc301e0bb67ef5051ea49c6 F src/sqliteLimit.h 164b0e6749d31e0daa1a4589a169d31c0dec7b3d @@ -935,7 +935,7 @@ F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224 F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e F tool/split-sqlite3c.tcl d9be87f1c340285a3e081eb19b4a247981ed290c F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f -P 5bde568028216f5bbf76fa0b61bf5b736699f4b1 -R 109bc7e0fff78b0c6554d3e5815c2cd8 -U dan -Z 5955a7caf010dc14908da2de85096565 +P 3e490915301216e242a5cdeb0febaff12ed53cb9 +R 40dc9cb79fe8b80783836d3c92828f73 +U drh +Z 8f56eea92b6efe4821fb2550b72615e0 diff --git a/manifest.uuid b/manifest.uuid index 2b5e8e05a9..adb4494110 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -3e490915301216e242a5cdeb0febaff12ed53cb9 \ No newline at end of file +8885c8677b239d4cbef24b9409a1736e1ae97a3f \ No newline at end of file diff --git a/src/sqlite.h.in b/src/sqlite.h.in index c83d0d70d4..26dab45cfe 100644 --- a/src/sqlite.h.in +++ b/src/sqlite.h.in @@ -2366,7 +2366,7 @@ void sqlite3_progress_handler(sqlite3*, int, int(*)(void*), void*); ** sqlite3_open_v2() can take one of ** the following three values, optionally combined with the ** [SQLITE_OPEN_NOMUTEX], [SQLITE_OPEN_FULLMUTEX], [SQLITE_OPEN_SHAREDCACHE], -** and/or [SQLITE_OPEN_PRIVATECACHE] flags:)^ +** [SQLITE_OPEN_PRIVATECACHE], and/or [SQLITE_OPEN_URI] flags:)^ ** **
    ** ^(
    [SQLITE_OPEN_READONLY]
    @@ -2385,9 +2385,8 @@ void sqlite3_progress_handler(sqlite3*, int, int(*)(void*), void*); **
    ** ** If the 3rd parameter to sqlite3_open_v2() is not one of the -** combinations shown above or one of the combinations shown above combined -** with the [SQLITE_OPEN_NOMUTEX], [SQLITE_OPEN_FULLMUTEX], -** [SQLITE_OPEN_SHAREDCACHE] and/or [SQLITE_OPEN_PRIVATECACHE] flags, +** combinations shown above optionally combined with other +** [SQLITE_OPEN_READONLY | SQLITE_OPEN_* bits] ** then the behavior is undefined. ** ** ^If the [SQLITE_OPEN_NOMUTEX] flag is set, then the database connection @@ -2419,27 +2418,36 @@ void sqlite3_progress_handler(sqlite3*, int, int(*)(void*), void*); ** on-disk database will be created. ^This private database will be ** automatically deleted as soon as the database connection is closed. ** -** ^If URI filename interpretation is enabled, and the filename argument +** [[URI filenames in sqlite3_open()]]

    URI Filenames

    +** +** ^If [URI filename] interpretation is enabled, and the filename argument ** begins with "file:", then the filename is interpreted as a URI. ^URI ** filename interpretation is enabled if the [SQLITE_OPEN_URI] flag is ** is set in the fourth argument to sqlite3_open_v2(), or if it has ** been enabled globally using the [SQLITE_CONFIG_URI] option with the -** [sqlite3_config()] method. +** [sqlite3_config()] method or by the [SQLITE_USE_URI] compile-time option. +** As of SQLite version 3.7.7, URI filename interpretation is turned off +** by default, but future releases of SQLite might enable URI filename +** intepretation by default. See "[URI filenames]" for additional +** information. ** -** URI filenames are parsed according to RFC 1738. If the URI contains an -** 'authority', then it must be either an empty string or the string +** URI filenames are parsed according to RFC 3986. ^If the URI contains an +** authority, then it must be either an empty string or the string ** "localhost". ^If the authority is not an empty string or "localhost", an -** error is returned to the caller. ^The 'fragment' component of a URI, if -** present, is always ignored. +** error is returned to the caller. ^The fragment component of a URI, if +** present, is ignored. ** -** ^SQLite uses the 'path' component of the URI as the path to the database file -** to open. ^If the path begins with a '/' character, then it is interpreted as -** an absolute path. ^If it does not begin with a '/', it is interpreted as a -** relative path. ^On windows, the first component of an absolute path +** ^SQLite uses the path component of the URI as the name of the disk file +** which contains the database. ^If the path begins with a '/' character, +** then it is interpreted as an absolute path. ^If the path does not begin +** with a '/' (meaning that the authority section is omitted from the URI) +** then the path is interpreted as a relative path. +** ^On windows, the first component of an absolute path ** is a drive specification (e.g. "C:"). ** +** [[core URI query parameters]] ** The query component of a URI may contain parameters that are interpreted -** either by SQLite itself, or by a [sqlite3_vfs | custom VFS implementation]. +** either by SQLite itself, or by a [VFS | custom VFS implementation]. ** SQLite interprets the following three query parameters: ** **
      @@ -2475,9 +2483,11 @@ void sqlite3_progress_handler(sqlite3*, int, int(*)(void*), void*); **
    ** ** ^Specifying an unknown parameter in the query component of a URI is not an -** error. +** error. Future versions of SQLite might understand additional query +** parameters. See "[query parameters with special meaning to SQLite]" for +** additional information. ** -** URI filename examples: +** [[URI filename examples]]

    URI filename examples

    ** ** **
    URI filenames Results From b706fe58ab4da3e1dd0d47377c05c2c02379f6d9 Mon Sep 17 00:00:00 2001 From: drh Date: Wed, 11 May 2011 20:54:32 +0000 Subject: [PATCH 25/40] Improvements to documentation hyperlinks. Change the value of SQLITE_OPEN_URI to an unreserved value. FossilOrigin-Name: 851ab75d5f5d64d95d6237c28658bbc32145b78b --- manifest | 12 ++-- manifest.uuid | 2 +- src/sqlite.h.in | 146 +++++++++++++++++++++++++++--------------------- 3 files changed, 89 insertions(+), 71 deletions(-) diff --git a/manifest b/manifest index 4d23d290be..9ed32b67a9 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C URI\sfilename\sdocumentation\supdates. -D 2011-05-11T19:00:10.252 +C Improvements\sto\sdocumentation\shyperlinks.\s\sChange\sthe\svalue\sof\nSQLITE_OPEN_URI\sto\san\sunreserved\svalue. +D 2011-05-11T20:54:32.761 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 7a4d9524721d40ef9ee26f93f9bd6a51dba106f2 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -179,7 +179,7 @@ F src/resolve.c 1c0f32b64f8e3f555fe1f732f9d6f501a7f05706 F src/rowset.c 69afa95a97c524ba6faf3805e717b5b7ae85a697 F src/select.c d9d440809025a58547e39f4f268c2a296bfb56ff F src/shell.c 72e7e176bf46d5c6518d15ac4ad6847c4bb5df79 -F src/sqlite.h.in 901b70703bb444d2c13b085e2cd2258b6a707e94 +F src/sqlite.h.in 26f123aa6f23b6cbd84d4ef6df3b8210a23a3b0b F src/sqlite3ext.h c90bd5507099f62043832d73f6425d8d5c5da754 F src/sqliteInt.h b34bd64a7ade4808fcc301e0bb67ef5051ea49c6 F src/sqliteLimit.h 164b0e6749d31e0daa1a4589a169d31c0dec7b3d @@ -935,7 +935,7 @@ F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224 F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e F tool/split-sqlite3c.tcl d9be87f1c340285a3e081eb19b4a247981ed290c F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f -P 3e490915301216e242a5cdeb0febaff12ed53cb9 -R 40dc9cb79fe8b80783836d3c92828f73 +P 8885c8677b239d4cbef24b9409a1736e1ae97a3f +R 4c0850c5e479c451c0b9f9d3c09b6b6d U drh -Z 8f56eea92b6efe4821fb2550b72615e0 +Z d48f7732010e4bf6308d6bb0dacbdaca diff --git a/manifest.uuid b/manifest.uuid index adb4494110..c35fe83711 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -8885c8677b239d4cbef24b9409a1736e1ae97a3f \ No newline at end of file +851ab75d5f5d64d95d6237c28658bbc32145b78b \ No newline at end of file diff --git a/src/sqlite.h.in b/src/sqlite.h.in index 26dab45cfe..8e041ac750 100644 --- a/src/sqlite.h.in +++ b/src/sqlite.h.in @@ -459,8 +459,7 @@ int sqlite3_exec( ** ** These bit values are intended for use in the ** 3rd parameter to the [sqlite3_open_v2()] interface and -** in the 4th parameter to the xOpen method of the -** [sqlite3_vfs] object. +** in the 4th parameter to the [sqlite3_vfs.xOpen] method. */ #define SQLITE_OPEN_READONLY 0x00000001 /* Ok for sqlite3_open_v2() */ #define SQLITE_OPEN_READWRITE 0x00000002 /* Ok for sqlite3_open_v2() */ @@ -468,6 +467,7 @@ int sqlite3_exec( #define SQLITE_OPEN_DELETEONCLOSE 0x00000008 /* VFS only */ #define SQLITE_OPEN_EXCLUSIVE 0x00000010 /* VFS only */ #define SQLITE_OPEN_AUTOPROXY 0x00000020 /* VFS only */ +#define SQLITE_OPEN_URI 0x00000040 /* Ok for sqlite3_open_v2() */ #define SQLITE_OPEN_MAIN_DB 0x00000100 /* VFS only */ #define SQLITE_OPEN_TEMP_DB 0x00000200 /* VFS only */ #define SQLITE_OPEN_TRANSIENT_DB 0x00000400 /* VFS only */ @@ -480,7 +480,6 @@ int sqlite3_exec( #define SQLITE_OPEN_SHAREDCACHE 0x00020000 /* Ok for sqlite3_open_v2() */ #define SQLITE_OPEN_PRIVATECACHE 0x00040000 /* Ok for sqlite3_open_v2() */ #define SQLITE_OPEN_WAL 0x00080000 /* VFS only */ -#define SQLITE_OPEN_URI 0x00100000 /* Ok for sqlite3_open_v2() */ /* Reserved: 0x00F00000 */ @@ -579,17 +578,18 @@ struct sqlite3_file { /* ** CAPI3REF: OS Interface File Virtual Methods Object ** -** Every file opened by the [sqlite3_vfs] xOpen method populates an +** Every file opened by the [sqlite3_vfs.xOpen] method populates an ** [sqlite3_file] object (or, more commonly, a subclass of the ** [sqlite3_file] object) with a pointer to an instance of this object. ** This object defines the methods used to perform various operations ** against the open file represented by the [sqlite3_file] object. ** -** If the xOpen method sets the sqlite3_file.pMethods element +** If the [sqlite3_vfs.xOpen] method sets the sqlite3_file.pMethods element ** to a non-NULL pointer, then the sqlite3_io_methods.xClose method -** may be invoked even if the xOpen reported that it failed. The -** only way to prevent a call to xClose following a failed xOpen -** is for the xOpen to set the sqlite3_file.pMethods element to NULL. +** may be invoked even if the [sqlite3_vfs.xOpen] reported that it failed. The +** only way to prevent a call to xClose following a failed [sqlite3_vfs.xOpen] +** is for the [sqlite3_vfs.xOpen] to set the sqlite3_file.pMethods element +** to NULL. ** ** The flags argument to xSync may be one of [SQLITE_SYNC_NORMAL] or ** [SQLITE_SYNC_FULL]. The first choice is the normal fsync(). @@ -791,6 +791,7 @@ typedef struct sqlite3_mutex sqlite3_mutex; ** The zName field holds the name of the VFS module. The name must ** be unique across all VFS modules. ** +** [[sqlite3_vfs.xOpen]] ** ^SQLite guarantees that the zFilename parameter to xOpen ** is either a NULL pointer or string obtained ** from xFullPathname() with an optional suffix added. @@ -868,6 +869,7 @@ typedef struct sqlite3_mutex sqlite3_mutex; ** element will be valid after xOpen returns regardless of the success ** or failure of the xOpen call. ** +** [[sqlite3_vfs.xAccess]] ** ^The flags argument to xAccess() may be [SQLITE_ACCESS_EXISTS] ** to test for the existence of a file, or [SQLITE_ACCESS_READWRITE] to ** test whether a file is readable and writable, or [SQLITE_ACCESS_READ] @@ -1114,9 +1116,9 @@ int sqlite3_os_end(void); ** implementation of an application-defined [sqlite3_os_init()]. ** ** The first argument to sqlite3_config() is an integer -** [SQLITE_CONFIG_SINGLETHREAD | configuration option] that determines +** [configuration option] that determines ** what property of SQLite is to be configured. Subsequent arguments -** vary depending on the [SQLITE_CONFIG_SINGLETHREAD | configuration option] +** vary depending on the [configuration option] ** in the first argument. ** ** ^When a configuration option is set, sqlite3_config() returns [SQLITE_OK]. @@ -1226,6 +1228,7 @@ struct sqlite3_mem_methods { /* ** CAPI3REF: Configuration Options +** KEYWORDS: {configuration option} ** ** These constants are the available integer configuration options that ** can be passed as the first argument to the [sqlite3_config()] interface. @@ -1238,7 +1241,7 @@ struct sqlite3_mem_methods { ** is invoked. ** **
    -**
    SQLITE_CONFIG_SINGLETHREAD
    +** [[SQLITE_CONFIG_SINGLETHREAD]]
    SQLITE_CONFIG_SINGLETHREAD
    **
    There are no arguments to this option. ^This option sets the ** [threading mode] to Single-thread. In other words, it disables ** all mutexing and puts SQLite into a mode where it can only be used @@ -1249,7 +1252,7 @@ struct sqlite3_mem_methods { ** [SQLITE_ERROR] if called with the SQLITE_CONFIG_SINGLETHREAD ** configuration option.
    ** -**
    SQLITE_CONFIG_MULTITHREAD
    +** [[SQLITE_CONFIG_MULTITHREAD]]
    SQLITE_CONFIG_MULTITHREAD
    **
    There are no arguments to this option. ^This option sets the ** [threading mode] to Multi-thread. In other words, it disables ** mutexing on [database connection] and [prepared statement] objects. @@ -1263,7 +1266,7 @@ struct sqlite3_mem_methods { ** [sqlite3_config()] will return [SQLITE_ERROR] if called with the ** SQLITE_CONFIG_MULTITHREAD configuration option.
    ** -**
    SQLITE_CONFIG_SERIALIZED
    +** [[SQLITE_CONFIG_SERIALIZED]]
    SQLITE_CONFIG_SERIALIZED
    **
    There are no arguments to this option. ^This option sets the ** [threading mode] to Serialized. In other words, this option enables ** all mutexes including the recursive @@ -1279,7 +1282,7 @@ struct sqlite3_mem_methods { ** [sqlite3_config()] will return [SQLITE_ERROR] if called with the ** SQLITE_CONFIG_SERIALIZED configuration option.
    ** -**
    SQLITE_CONFIG_MALLOC
    +** [[SQLITE_CONFIG_MALLOC]]
    SQLITE_CONFIG_MALLOC
    **
    ^(This option takes a single argument which is a pointer to an ** instance of the [sqlite3_mem_methods] structure. The argument specifies ** alternative low-level memory allocation routines to be used in place of @@ -1287,7 +1290,7 @@ struct sqlite3_mem_methods { ** its own private copy of the content of the [sqlite3_mem_methods] structure ** before the [sqlite3_config()] call returns.
    ** -**
    SQLITE_CONFIG_GETMALLOC
    +** [[SQLITE_CONFIG_GETMALLOC]]
    SQLITE_CONFIG_GETMALLOC
    **
    ^(This option takes a single argument which is a pointer to an ** instance of the [sqlite3_mem_methods] structure. The [sqlite3_mem_methods] ** structure is filled with the currently defined memory allocation routines.)^ @@ -1295,7 +1298,7 @@ struct sqlite3_mem_methods { ** routines with a wrapper that simulations memory allocation failure or ** tracks memory usage, for example.
    ** -**
    SQLITE_CONFIG_MEMSTATUS
    +** [[SQLITE_CONFIG_MEMSTATUS]]
    SQLITE_CONFIG_MEMSTATUS
    **
    ^This option takes single argument of type int, interpreted as a ** boolean, which enables or disables the collection of memory allocation ** statistics. ^(When memory allocation statistics are disabled, the @@ -1311,7 +1314,7 @@ struct sqlite3_mem_methods { ** allocation statistics are disabled by default. **
    ** -**
    SQLITE_CONFIG_SCRATCH
    +** [[SQLITE_CONFIG_SCRATCH]]
    SQLITE_CONFIG_SCRATCH
    **
    ^This option specifies a static memory buffer that SQLite can use for ** scratch memory. There are three arguments: A pointer an 8-byte ** aligned memory buffer from which the scratch allocations will be @@ -1327,7 +1330,7 @@ struct sqlite3_mem_methods { ** scratch memory beyond what is provided by this configuration option, then ** [sqlite3_malloc()] will be used to obtain the memory needed.
    ** -**
    SQLITE_CONFIG_PAGECACHE
    +** [[SQLITE_CONFIG_PAGECACHE]]
    SQLITE_CONFIG_PAGECACHE
    **
    ^This option specifies a static memory buffer that SQLite can use for ** the database page cache with the default page cache implemenation. ** This configuration should not be used if an application-define page @@ -1348,7 +1351,7 @@ struct sqlite3_mem_methods { ** be aligned to an 8-byte boundary or subsequent behavior of SQLite ** will be undefined.
    ** -**
    SQLITE_CONFIG_HEAP
    +** [[SQLITE_CONFIG_HEAP]]
    SQLITE_CONFIG_HEAP
    **
    ^This option specifies a static memory buffer that SQLite will use ** for all of its dynamic memory allocation needs beyond those provided ** for by [SQLITE_CONFIG_SCRATCH] and [SQLITE_CONFIG_PAGECACHE]. @@ -1365,7 +1368,7 @@ struct sqlite3_mem_methods { ** The minimum allocation size is capped at 2^12. Reasonable values ** for the minimum allocation size are 2^5 through 2^8.
    ** -**
    SQLITE_CONFIG_MUTEX
    +** [[SQLITE_CONFIG_MUTEX]]
    SQLITE_CONFIG_MUTEX
    **
    ^(This option takes a single argument which is a pointer to an ** instance of the [sqlite3_mutex_methods] structure. The argument specifies ** alternative low-level mutex routines to be used in place @@ -1377,7 +1380,7 @@ struct sqlite3_mem_methods { ** [sqlite3_config()] with the SQLITE_CONFIG_MUTEX configuration option will ** return [SQLITE_ERROR].
    ** -**
    SQLITE_CONFIG_GETMUTEX
    +** [[SQLITE_CONFIG_GETMUTEX]]
    SQLITE_CONFIG_GETMUTEX
    **
    ^(This option takes a single argument which is a pointer to an ** instance of the [sqlite3_mutex_methods] structure. The ** [sqlite3_mutex_methods] @@ -1390,7 +1393,7 @@ struct sqlite3_mem_methods { ** [sqlite3_config()] with the SQLITE_CONFIG_GETMUTEX configuration option will ** return [SQLITE_ERROR].
    ** -**
    SQLITE_CONFIG_LOOKASIDE
    +** [[SQLITE_CONFIG_LOOKASIDE]]
    SQLITE_CONFIG_LOOKASIDE
    **
    ^(This option takes two arguments that determine the default ** memory allocation for the lookaside memory allocator on each ** [database connection]. The first argument is the @@ -1400,18 +1403,18 @@ struct sqlite3_mem_methods { ** verb to [sqlite3_db_config()] can be used to change the lookaside ** configuration on individual connections.)^
    ** -**
    SQLITE_CONFIG_PCACHE
    +** [[SQLITE_CONFIG_PCACHE]]
    SQLITE_CONFIG_PCACHE
    **
    ^(This option takes a single argument which is a pointer to ** an [sqlite3_pcache_methods] object. This object specifies the interface ** to a custom page cache implementation.)^ ^SQLite makes a copy of the ** object and uses it for page cache memory allocations.
    ** -**
    SQLITE_CONFIG_GETPCACHE
    +** [[SQLITE_CONFIG_GETPCACHE]]
    SQLITE_CONFIG_GETPCACHE
    **
    ^(This option takes a single argument which is a pointer to an ** [sqlite3_pcache_methods] object. SQLite copies of the current ** page cache implementation into that object.)^
    ** -**
    SQLITE_CONFIG_LOG
    +** [[SQLITE_CONFIG_LOG]]
    SQLITE_CONFIG_LOG
    **
    ^The SQLITE_CONFIG_LOG option takes two arguments: a pointer to a ** function with a call signature of void(*)(void*,int,const char*), ** and a pointer to void. ^If the function pointer is not NULL, it is @@ -1429,7 +1432,7 @@ struct sqlite3_mem_methods { ** In a multi-threaded application, the application-defined logger ** function must be threadsafe.
    ** -**
    SQLITE_CONFIG_URI +** [[SQLITE_CONFIG_URI]]
    SQLITE_CONFIG_URI **
    This option takes a single argument of type int. If non-zero, then ** URI handling is globally enabled. If the parameter is zero, then URI handling ** is globally disabled. If URI handling is globally enabled, all filenames @@ -2660,43 +2663,45 @@ int sqlite3_limit(sqlite3*, int id, int newVal); ** Additional information is available at [limits | Limits in SQLite]. ** **
    -** ^(
    SQLITE_LIMIT_LENGTH
    +** [[SQLITE_LIMIT_LENGTH]] ^(
    SQLITE_LIMIT_LENGTH
    **
    The maximum size of any string or BLOB or table row, in bytes.
    )^ ** -** ^(
    SQLITE_LIMIT_SQL_LENGTH
    +** [[SQLITE_LIMIT_SQL_LENGTH]] ^(
    SQLITE_LIMIT_SQL_LENGTH
    **
    The maximum length of an SQL statement, in bytes.
    )^ ** -** ^(
    SQLITE_LIMIT_COLUMN
    +** [[SQLITE_LIMIT_COLUMN]] ^(
    SQLITE_LIMIT_COLUMN
    **
    The maximum number of columns in a table definition or in the ** result set of a [SELECT] or the maximum number of columns in an index ** or in an ORDER BY or GROUP BY clause.
    )^ ** -** ^(
    SQLITE_LIMIT_EXPR_DEPTH
    +** [[SQLITE_LIMIT_EXPR_DEPTH]] ^(
    SQLITE_LIMIT_EXPR_DEPTH
    **
    The maximum depth of the parse tree on any expression.
    )^ ** -** ^(
    SQLITE_LIMIT_COMPOUND_SELECT
    +** [[SQLITE_LIMIT_COMPOUND_SELECT]] ^(
    SQLITE_LIMIT_COMPOUND_SELECT
    **
    The maximum number of terms in a compound SELECT statement.
    )^ ** -** ^(
    SQLITE_LIMIT_VDBE_OP
    +** [[SQLITE_LIMIT_VDBE_OP]] ^(
    SQLITE_LIMIT_VDBE_OP
    **
    The maximum number of instructions in a virtual machine program ** used to implement an SQL statement. This limit is not currently ** enforced, though that might be added in some future release of ** SQLite.
    )^ ** -** ^(
    SQLITE_LIMIT_FUNCTION_ARG
    +** [[SQLITE_LIMIT_FUNCTION_ARG]] ^(
    SQLITE_LIMIT_FUNCTION_ARG
    **
    The maximum number of arguments on a function.
    )^ ** -** ^(
    SQLITE_LIMIT_ATTACHED
    +** [[SQLITE_LIMIT_ATTACHED]] ^(
    SQLITE_LIMIT_ATTACHED
    **
    The maximum number of [ATTACH | attached databases].)^
    ** +** [[SQLITE_LIMIT_LIKE_PATTERN_LENGTH]] ** ^(
    SQLITE_LIMIT_LIKE_PATTERN_LENGTH
    **
    The maximum length of the pattern argument to the [LIKE] or ** [GLOB] operators.
    )^ ** +** [[SQLITE_LIMIT_VARIABLE_NUMBER]] ** ^(
    SQLITE_LIMIT_VARIABLE_NUMBER
    **
    The maximum index number of any [parameter] in an SQL statement.)^ ** -** ^(
    SQLITE_LIMIT_TRIGGER_DEPTH
    +** [[SQLITE_LIMIT_TRIGGER_DEPTH]] ^(
    SQLITE_LIMIT_TRIGGER_DEPTH
    **
    The maximum depth of recursion for triggers.
    )^ **
    */ @@ -5550,7 +5555,7 @@ int sqlite3_test_control(int op, ...); ** about the performance of SQLite, and optionally to reset various ** highwater marks. ^The first argument is an integer code for ** the specific parameter to measure. ^(Recognized integer codes -** are of the form [SQLITE_STATUS_MEMORY_USED | SQLITE_STATUS_...].)^ +** are of the form [status parameters | SQLITE_STATUS_...].)^ ** ^The current value of the parameter is returned into *pCurrent. ** ^The highest recorded value is returned in *pHighwater. ^If the ** resetFlag is true, then the highest record value is reset after @@ -5577,12 +5582,13 @@ int sqlite3_status(int op, int *pCurrent, int *pHighwater, int resetFlag); /* ** CAPI3REF: Status Parameters +** KEYWORDS: {status parameters} ** ** These integer constants designate various run-time status parameters ** that can be returned by [sqlite3_status()]. ** **
    -** ^(
    SQLITE_STATUS_MEMORY_USED
    +** [[SQLITE_STATUS_MEMORY_USED]] ^(
    SQLITE_STATUS_MEMORY_USED
    **
    This parameter is the current amount of memory checked out ** using [sqlite3_malloc()], either directly or indirectly. The ** figure includes calls made to [sqlite3_malloc()] by the application @@ -5592,23 +5598,24 @@ int sqlite3_status(int op, int *pCurrent, int *pHighwater, int resetFlag); ** this parameter. The amount returned is the sum of the allocation ** sizes as reported by the xSize method in [sqlite3_mem_methods].
    )^ ** -** ^(
    SQLITE_STATUS_MALLOC_SIZE
    +** [[SQLITE_STATUS_MALLOC_SIZE]] ^(
    SQLITE_STATUS_MALLOC_SIZE
    **
    This parameter records the largest memory allocation request ** handed to [sqlite3_malloc()] or [sqlite3_realloc()] (or their ** internal equivalents). Only the value returned in the ** *pHighwater parameter to [sqlite3_status()] is of interest. ** The value written into the *pCurrent parameter is undefined.
    )^ ** -** ^(
    SQLITE_STATUS_MALLOC_COUNT
    +** [[SQLITE_STATUS_MALLOC_COUNT]] ^(
    SQLITE_STATUS_MALLOC_COUNT
    **
    This parameter records the number of separate memory allocations ** currently checked out.
    )^ ** -** ^(
    SQLITE_STATUS_PAGECACHE_USED
    +** [[SQLITE_STATUS_PAGECACHE_USED]] ^(
    SQLITE_STATUS_PAGECACHE_USED
    **
    This parameter returns the number of pages used out of the ** [pagecache memory allocator] that was configured using ** [SQLITE_CONFIG_PAGECACHE]. The ** value returned is in pages, not in bytes.
    )^ ** +** [[SQLITE_STATUS_PAGECACHE_OVERFLOW]] ** ^(
    SQLITE_STATUS_PAGECACHE_OVERFLOW
    **
    This parameter returns the number of bytes of page cache ** allocation which could not be satisfied by the [SQLITE_CONFIG_PAGECACHE] @@ -5618,13 +5625,13 @@ int sqlite3_status(int op, int *pCurrent, int *pHighwater, int resetFlag); ** [SQLITE_CONFIG_PAGECACHE]) and allocations that overflowed because ** no space was left in the page cache.
    )^ ** -** ^(
    SQLITE_STATUS_PAGECACHE_SIZE
    +** [[SQLITE_STATUS_PAGECACHE_SIZE]] ^(
    SQLITE_STATUS_PAGECACHE_SIZE
    **
    This parameter records the largest memory allocation request ** handed to [pagecache memory allocator]. Only the value returned in the ** *pHighwater parameter to [sqlite3_status()] is of interest. ** The value written into the *pCurrent parameter is undefined.
    )^ ** -** ^(
    SQLITE_STATUS_SCRATCH_USED
    +** [[SQLITE_STATUS_SCRATCH_USED]] ^(
    SQLITE_STATUS_SCRATCH_USED
    **
    This parameter returns the number of allocations used out of the ** [scratch memory allocator] configured using ** [SQLITE_CONFIG_SCRATCH]. The value returned is in allocations, not @@ -5632,7 +5639,7 @@ int sqlite3_status(int op, int *pCurrent, int *pHighwater, int resetFlag); ** outstanding at time, this parameter also reports the number of threads ** using scratch memory at the same time.
    )^ ** -** ^(
    SQLITE_STATUS_SCRATCH_OVERFLOW
    +** [[SQLITE_STATUS_SCRATCH_OVERFLOW]] ^(
    SQLITE_STATUS_SCRATCH_OVERFLOW
    **
    This parameter returns the number of bytes of scratch memory ** allocation which could not be satisfied by the [SQLITE_CONFIG_SCRATCH] ** buffer and where forced to overflow to [sqlite3_malloc()]. The values @@ -5642,13 +5649,13 @@ int sqlite3_status(int op, int *pCurrent, int *pHighwater, int resetFlag); ** slots were available. **
    )^ ** -** ^(
    SQLITE_STATUS_SCRATCH_SIZE
    +** [[SQLITE_STATUS_SCRATCH_SIZE]] ^(
    SQLITE_STATUS_SCRATCH_SIZE
    **
    This parameter records the largest memory allocation request ** handed to [scratch memory allocator]. Only the value returned in the ** *pHighwater parameter to [sqlite3_status()] is of interest. ** The value written into the *pCurrent parameter is undefined.
    )^ ** -** ^(
    SQLITE_STATUS_PARSER_STACK
    +** [[SQLITE_STATUS_PARSER_STACK]] ^(
    SQLITE_STATUS_PARSER_STACK
    **
    This parameter records the deepest parser stack. It is only ** meaningful if SQLite is compiled with [YYTRACKMAXSTACKDEPTH].
    )^ **
    @@ -5673,9 +5680,9 @@ int sqlite3_status(int op, int *pCurrent, int *pHighwater, int resetFlag); ** about a single [database connection]. ^The first argument is the ** database connection object to be interrogated. ^The second argument ** is an integer constant, taken from the set of -** [SQLITE_DBSTATUS_LOOKASIDE_USED | SQLITE_DBSTATUS_*] macros, that +** [SQLITE_DBSTATUS options], that ** determines the parameter to interrogate. The set of -** [SQLITE_DBSTATUS_LOOKASIDE_USED | SQLITE_DBSTATUS_*] macros is likely +** [SQLITE_DBSTATUS options] is likely ** to grow in future releases of SQLite. ** ** ^The current value of the requested parameter is written into *pCur @@ -5692,6 +5699,7 @@ int sqlite3_db_status(sqlite3*, int op, int *pCur, int *pHiwtr, int resetFlg); /* ** CAPI3REF: Status Parameters for database connections +** KEYWORDS: {SQLITE_DBSTATUS options} ** ** These constants are the available integer "verbs" that can be passed as ** the second argument to the [sqlite3_db_status()] interface. @@ -5703,15 +5711,16 @@ int sqlite3_db_status(sqlite3*, int op, int *pCur, int *pHiwtr, int resetFlg); ** if a discontinued or unsupported verb is invoked. ** **
    -** ^(
    SQLITE_DBSTATUS_LOOKASIDE_USED
    +** [[SQLITE_DBSTATUS_LOOKASIDE_USED]] ^(
    SQLITE_DBSTATUS_LOOKASIDE_USED
    **
    This parameter returns the number of lookaside memory slots currently ** checked out.
    )^ ** -** ^(
    SQLITE_DBSTATUS_LOOKASIDE_HIT
    +** [[SQLITE_DBSTATUS_LOOKASIDE_HIT]] ^(
    SQLITE_DBSTATUS_LOOKASIDE_HIT
    **
    This parameter returns the number malloc attempts that were ** satisfied using lookaside memory. Only the high-water value is meaningful; ** the current value is always zero.)^ ** +** [[SQLITE_DBSTATUS_LOOKASIDE_MISS_SIZE]] ** ^(
    SQLITE_DBSTATUS_LOOKASIDE_MISS_SIZE
    **
    This parameter returns the number malloc attempts that might have ** been satisfied using lookaside memory but failed due to the amount of @@ -5719,6 +5728,7 @@ int sqlite3_db_status(sqlite3*, int op, int *pCur, int *pHiwtr, int resetFlg); ** Only the high-water value is meaningful; ** the current value is always zero.)^ ** +** [[SQLITE_DBSTATUS_LOOKASIDE_MISS_FULL]] ** ^(
    SQLITE_DBSTATUS_LOOKASIDE_MISS_FULL
    **
    This parameter returns the number malloc attempts that might have ** been satisfied using lookaside memory but failed due to all lookaside @@ -5726,12 +5736,12 @@ int sqlite3_db_status(sqlite3*, int op, int *pCur, int *pHiwtr, int resetFlg); ** Only the high-water value is meaningful; ** the current value is always zero.)^ ** -** ^(
    SQLITE_DBSTATUS_CACHE_USED
    +** [[SQLITE_DBSTATUS_CACHE_USED]] ^(
    SQLITE_DBSTATUS_CACHE_USED
    **
    This parameter returns the approximate number of of bytes of heap ** memory used by all pager caches associated with the database connection.)^ ** ^The highwater mark associated with SQLITE_DBSTATUS_CACHE_USED is always 0. ** -** ^(
    SQLITE_DBSTATUS_SCHEMA_USED
    +** [[SQLITE_DBSTATUS_SCHEMA_USED]] ^(
    SQLITE_DBSTATUS_SCHEMA_USED
    **
    This parameter returns the approximate number of of bytes of heap ** memory used to store the schema for all databases associated ** with the connection - main, temp, and any [ATTACH]-ed databases.)^ @@ -5740,7 +5750,7 @@ int sqlite3_db_status(sqlite3*, int op, int *pCur, int *pHiwtr, int resetFlg); ** [shared cache mode] being enabled. ** ^The highwater mark associated with SQLITE_DBSTATUS_SCHEMA_USED is always 0. ** -** ^(
    SQLITE_DBSTATUS_STMT_USED
    +** [[SQLITE_DBSTATUS_STMT_USED]] ^(
    SQLITE_DBSTATUS_STMT_USED
    **
    This parameter returns the approximate number of of bytes of heap ** and lookaside memory used by all prepared statements associated with ** the database connection.)^ @@ -5762,7 +5772,7 @@ int sqlite3_db_status(sqlite3*, int op, int *pCur, int *pHiwtr, int resetFlg); ** CAPI3REF: Prepared Statement Status ** ** ^(Each prepared statement maintains various -** [SQLITE_STMTSTATUS_SORT | counters] that measure the number +** [SQLITE_STMTSTATUS counters] that measure the number ** of times it has performed specific operations.)^ These counters can ** be used to monitor the performance characteristics of the prepared ** statements. For example, if the number of table steps greatly exceeds @@ -5773,7 +5783,7 @@ int sqlite3_db_status(sqlite3*, int op, int *pCur, int *pHiwtr, int resetFlg); ** ^(This interface is used to retrieve and reset counter values from ** a [prepared statement]. The first argument is the prepared statement ** object to be interrogated. The second argument -** is an integer code for a specific [SQLITE_STMTSTATUS_SORT | counter] +** is an integer code for a specific [SQLITE_STMTSTATUS counter] ** to be interrogated.)^ ** ^The current value of the requested counter is returned. ** ^If the resetFlg is true, then the counter is reset to zero after this @@ -5785,24 +5795,25 @@ int sqlite3_stmt_status(sqlite3_stmt*, int op,int resetFlg); /* ** CAPI3REF: Status Parameters for prepared statements +** KEYWORDS: {SQLITE_STMTSTATUS counter} {SQLITE_STMTSTATUS counters} ** ** These preprocessor macros define integer codes that name counter ** values associated with the [sqlite3_stmt_status()] interface. ** The meanings of the various counters are as follows: ** **
    -**
    SQLITE_STMTSTATUS_FULLSCAN_STEP
    +** [[SQLITE_STMTSTATUS_FULLSCAN_STEP]]
    SQLITE_STMTSTATUS_FULLSCAN_STEP
    **
    ^This is the number of times that SQLite has stepped forward in ** a table as part of a full table scan. Large numbers for this counter ** may indicate opportunities for performance improvement through ** careful use of indices.
    ** -**
    SQLITE_STMTSTATUS_SORT
    +** [[SQLITE_STMTSTATUS_SORT]]
    SQLITE_STMTSTATUS_SORT
    **
    ^This is the number of sort operations that have occurred. ** A non-zero value in this counter may indicate an opportunity to ** improvement performance through careful use of indices.
    ** -**
    SQLITE_STMTSTATUS_AUTOINDEX
    +** [[SQLITE_STMTSTATUS_AUTOINDEX]]
    SQLITE_STMTSTATUS_AUTOINDEX
    **
    ^This is the number of rows inserted into transient indices that ** were created automatically in order to help joins run faster. ** A non-zero value in this counter may indicate an opportunity to @@ -5853,6 +5864,7 @@ typedef struct sqlite3_pcache sqlite3_pcache; ** the application may discard the parameter after the call to ** [sqlite3_config()] returns.)^ ** +** [[the xInit() page cache method]] ** ^(The xInit() method is called once for each effective ** call to [sqlite3_initialize()])^ ** (usually only once during the lifetime of the process). ^(The xInit() @@ -5863,6 +5875,7 @@ typedef struct sqlite3_pcache sqlite3_pcache; ** built-in default page cache is used instead of the application defined ** page cache.)^ ** +** [[the xShutdown() page cache method]] ** ^The xShutdown() method is called by [sqlite3_shutdown()]. ** It can be used to clean up ** any outstanding resources before process shutdown, if required. @@ -5877,6 +5890,7 @@ typedef struct sqlite3_pcache sqlite3_pcache; ** ^SQLite will never invoke xInit() more than once without an intervening ** call to xShutdown(). ** +** [[the xCreate() page cache methods]] ** ^SQLite invokes the xCreate() method to construct a new cache instance. ** SQLite will typically create one cache instance for each open database file, ** though this is not guaranteed. ^The @@ -5901,6 +5915,7 @@ typedef struct sqlite3_pcache sqlite3_pcache; ** ^Hence, a cache created with bPurgeable false will ** never contain any unpinned pages. ** +** [[the xCachesize() page cache method]] ** ^(The xCachesize() method may be called at any time by SQLite to set the ** suggested maximum cache-size (number of pages stored by) the cache ** instance passed as the first argument. This is the value configured using @@ -5908,9 +5923,11 @@ typedef struct sqlite3_pcache sqlite3_pcache; ** parameter, the implementation is not required to do anything with this ** value; it is advisory only. ** +** [[the xPagecount() page cache methods]] ** The xPagecount() method must return the number of pages currently ** stored in the cache, both pinned and unpinned. ** +** [[the xFetch() page cache methods]] ** The xFetch() method locates a page in the cache and returns a pointer to ** the page, or a NULL pointer. ** A "page", in this context, means a buffer of szPage bytes aligned at an @@ -5939,6 +5956,7 @@ typedef struct sqlite3_pcache sqlite3_pcache; ** attempt to unpin one or more cache pages by spilling the content of ** pinned pages to disk and synching the operating system disk cache. ** +** [[the xUnpin() page cache method]] ** ^xUnpin() is called by SQLite with a pointer to a currently pinned page ** as its second argument. If the third parameter, discard, is non-zero, ** then the page must be evicted from the cache. @@ -5951,6 +5969,7 @@ typedef struct sqlite3_pcache sqlite3_pcache; ** call to xUnpin() unpins the page regardless of the number of prior calls ** to xFetch(). ** +** [[the xRekey() page cache methods]] ** The xRekey() method is used to change the key value associated with the ** page passed as the second argument. If the cache ** previously contains an entry associated with newKey, it must be @@ -5963,6 +5982,7 @@ typedef struct sqlite3_pcache sqlite3_pcache; ** of these pages are pinned, they are implicitly unpinned, meaning that ** they can be safely discarded. ** +** [[the xDestroy() page cache method]] ** ^The xDestroy() method is used to delete a cache allocated by xCreate(). ** All resources associated with the specified cache should be freed. ^After ** calling the xDestroy() method, SQLite considers the [sqlite3_pcache*] @@ -6025,7 +6045,7 @@ typedef struct sqlite3_backup sqlite3_backup; ** There should be exactly one call to sqlite3_backup_finish() for each ** successful call to sqlite3_backup_init(). ** -** sqlite3_backup_init() +** [[sqlite3_backup_init()]] sqlite3_backup_init() ** ** ^The D and N arguments to sqlite3_backup_init(D,N,S,M) are the ** [database connection] associated with the destination database @@ -6052,7 +6072,7 @@ typedef struct sqlite3_backup sqlite3_backup; ** sqlite3_backup_finish() functions to perform the specified backup ** operation. ** -** sqlite3_backup_step() +** [[sqlite3_backup_step()]] sqlite3_backup_step() ** ** ^Function sqlite3_backup_step(B,N) will copy up to N pages between ** the source and destination databases specified by [sqlite3_backup] object B. @@ -6109,7 +6129,7 @@ typedef struct sqlite3_backup sqlite3_backup; ** by the backup operation, then the backup database is automatically ** updated at the same time. ** -** sqlite3_backup_finish() +** [[sqlite3_backup_finish()]] sqlite3_backup_finish() ** ** When sqlite3_backup_step() has returned [SQLITE_DONE], or when the ** application wishes to abandon the backup operation, the application @@ -6132,7 +6152,8 @@ typedef struct sqlite3_backup sqlite3_backup; ** is not a permanent error and does not affect the return value of ** sqlite3_backup_finish(). ** -** sqlite3_backup_remaining(), sqlite3_backup_pagecount() +** [[sqlite3_backup__remaining()]] [[sqlite3_backup_pagecount()]] +** sqlite3_backup_remaining() and sqlite3_backup_pagecount() ** ** ^Each call to sqlite3_backup_step() sets two values inside ** the [sqlite3_backup] object: the number of pages still to be backed @@ -6513,9 +6534,6 @@ int sqlite3_wal_checkpoint_v2( ** [sqlite3_wal_checkpoint_v2()]. See the [sqlite3_wal_checkpoint_v2()] ** documentation for additional information about the meaning and use of ** each of these values. -** -**
    SQLITE_CONFIG_GETMUTEX
    -**
    ^(This option takes a single argument which is a pointer to an */ #define SQLITE_CHECKPOINT_PASSIVE 0 #define SQLITE_CHECKPOINT_FULL 1 From 671b52242b48bb1e5a99c8937a7ff4cf9e283c59 Mon Sep 17 00:00:00 2001 From: shaneh Date: Thu, 12 May 2011 21:01:12 +0000 Subject: [PATCH 26/40] Add fts3_term.c to amalg gen script and configure input files. FossilOrigin-Name: 6ee0773290a4c4aac2b2b5e1741e65170e08a8bb --- Makefile.in | 11 ++++++++--- manifest | 16 ++++++++-------- manifest.uuid | 2 +- tool/mksqlite3c.tcl | 1 + 4 files changed, 18 insertions(+), 12 deletions(-) diff --git a/Makefile.in b/Makefile.in index f3239f3d79..01c4010b8e 100644 --- a/Makefile.in +++ b/Makefile.in @@ -166,7 +166,7 @@ LIBOBJS0 = alter.lo analyze.lo attach.lo auth.lo \ callback.lo complete.lo ctime.lo date.lo delete.lo \ expr.lo fault.lo fkey.lo \ fts3.lo fts3_aux.lo fts3_expr.lo fts3_hash.lo fts3_icu.lo fts3_porter.lo \ - fts3_snippet.lo fts3_tokenizer.lo fts3_tokenizer1.lo fts3_write.lo \ + fts3_snippet.lo fts3_term.lo fts3_tokenizer.lo fts3_tokenizer1.lo fts3_write.lo \ func.lo global.lo hash.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 \ @@ -313,6 +313,7 @@ SRC += \ $(TOP)/ext/fts3/fts3_icu.c \ $(TOP)/ext/fts3/fts3_porter.c \ $(TOP)/ext/fts3/fts3_snippet.c \ + $(TOP)/ext/fts3/fts3_term.c \ $(TOP)/ext/fts3/fts3_tokenizer.h \ $(TOP)/ext/fts3/fts3_tokenizer.c \ $(TOP)/ext/fts3/fts3_tokenizer1.c \ @@ -420,6 +421,7 @@ TESTSRC2 = \ $(TOP)/ext/fts3/fts3.c \ $(TOP)/ext/fts3/fts3_aux.c \ $(TOP)/ext/fts3/fts3_expr.c \ + $(TOP)/ext/fts3/fts3_term.c \ $(TOP)/ext/fts3/fts3_tokenizer.c \ $(TOP)/ext/fts3/fts3_write.c \ $(TOP)/ext/async/sqlite3async.c @@ -828,11 +830,14 @@ fts3_hash.lo: $(TOP)/ext/fts3/fts3_hash.c $(HDR) $(EXTHDR) fts3_icu.lo: $(TOP)/ext/fts3/fts3_icu.c $(HDR) $(EXTHDR) $(LTCOMPILE) -DSQLITE_CORE -c $(TOP)/ext/fts3/fts3_icu.c +fts3_porter.lo: $(TOP)/ext/fts3/fts3_porter.c $(HDR) $(EXTHDR) + $(LTCOMPILE) -DSQLITE_CORE -c $(TOP)/ext/fts3/fts3_porter.c + fts3_snippet.lo: $(TOP)/ext/fts3/fts3_snippet.c $(HDR) $(EXTHDR) $(LTCOMPILE) -DSQLITE_CORE -c $(TOP)/ext/fts3/fts3_snippet.c -fts3_porter.lo: $(TOP)/ext/fts3/fts3_porter.c $(HDR) $(EXTHDR) - $(LTCOMPILE) -DSQLITE_CORE -c $(TOP)/ext/fts3/fts3_porter.c +fts3_term.lo: $(TOP)/ext/fts3/fts3_term.c $(HDR) $(EXTHDR) + $(LTCOMPILE) -DSQLITE_CORE -c $(TOP)/ext/fts3/fts3_term.c fts3_tokenizer.lo: $(TOP)/ext/fts3/fts3_tokenizer.c $(HDR) $(EXTHDR) $(LTCOMPILE) -DSQLITE_CORE -c $(TOP)/ext/fts3/fts3_tokenizer.c diff --git a/manifest b/manifest index 9ed32b67a9..1415b061f0 100644 --- a/manifest +++ b/manifest @@ -1,7 +1,7 @@ -C Improvements\sto\sdocumentation\shyperlinks.\s\sChange\sthe\svalue\sof\nSQLITE_OPEN_URI\sto\san\sunreserved\svalue. -D 2011-05-11T20:54:32.761 +C Add\sfts3_term.c\sto\samalg\sgen\sscript\sand\sconfigure\sinput\sfiles. +D 2011-05-12T21:01:12.782 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f -F Makefile.in 7a4d9524721d40ef9ee26f93f9bd6a51dba106f2 +F Makefile.in 4a7ed220f2e9a068fd0f0b2ec451439f63e629fc F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 F Makefile.vxworks c85ec1d8597fe2f7bc225af12ac1666e21379151 F README cd04a36fbc7ea56932a4052d7d0b7f09f27c33d6 @@ -910,7 +910,7 @@ F tool/lempar.c 01ca97f87610d1dac6d8cd96ab109ab1130e76dc F tool/mkkeywordhash.c d2e6b4a5965e23afb80fbe74bb54648cd371f309 F tool/mkopts.tcl 66ac10d240cc6e86abd37dc908d50382f84ff46e F tool/mkspeedsql.tcl a1a334d288f7adfe6e996f2e712becf076745c97 -F tool/mksqlite3c.tcl 623e26cc8c83322e4151d3ad85ac69d41221bae8 +F tool/mksqlite3c.tcl d171512b785283690b6f80997bee974c80087a23 F tool/mksqlite3h.tcl d76c226a5e8e1f3b5f6593bcabe5e98b3b1ec9ff F tool/mksqlite3internalh.tcl 7b43894e21bcb1bb39e11547ce7e38a063357e87 F tool/omittest.tcl b1dd290c1596e0f31fd335160a74ec5dfea3df4a @@ -935,7 +935,7 @@ F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224 F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e F tool/split-sqlite3c.tcl d9be87f1c340285a3e081eb19b4a247981ed290c F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f -P 8885c8677b239d4cbef24b9409a1736e1ae97a3f -R 4c0850c5e479c451c0b9f9d3c09b6b6d -U drh -Z d48f7732010e4bf6308d6bb0dacbdaca +P 851ab75d5f5d64d95d6237c28658bbc32145b78b +R f2444b92fe2cfe7d047908f98416ca93 +U shaneh +Z aec7145a879a050a92e29403b1ef0483 diff --git a/manifest.uuid b/manifest.uuid index c35fe83711..f29a126a22 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -851ab75d5f5d64d95d6237c28658bbc32145b78b \ No newline at end of file +6ee0773290a4c4aac2b2b5e1741e65170e08a8bb \ No newline at end of file diff --git a/tool/mksqlite3c.tcl b/tool/mksqlite3c.tcl index fa99f2df7b..f88ca08887 100644 --- a/tool/mksqlite3c.tcl +++ b/tool/mksqlite3c.tcl @@ -298,6 +298,7 @@ foreach file { fts3_expr.c fts3_hash.c fts3_porter.c + fts3_term.c fts3_tokenizer.c fts3_tokenizer1.c fts3_write.c From 79d0e1c0a73f27735029a64879d84a6652ea567c Mon Sep 17 00:00:00 2001 From: drh Date: Fri, 13 May 2011 17:11:20 +0000 Subject: [PATCH 27/40] Also add fts3_term.c to main.mk. FossilOrigin-Name: 966f2d2c1f01b6345eab5df87a40d337ced1c087 --- main.mk | 8 ++++++-- manifest | 14 +++++++------- manifest.uuid | 2 +- 3 files changed, 14 insertions(+), 10 deletions(-) diff --git a/main.mk b/main.mk index 3df069a71d..0035743003 100644 --- a/main.mk +++ b/main.mk @@ -54,8 +54,8 @@ LIBOBJ+= alter.o analyze.o attach.o auth.o \ backup.o bitvec.o btmutex.o btree.o build.o \ callback.o complete.o ctime.o date.o delete.o expr.o fault.o fkey.o \ fts3.o fts3_aux.o fts3_expr.o fts3_hash.o fts3_icu.o fts3_porter.o \ - fts3_snippet.o fts3_tokenizer.o fts3_tokenizer1.o fts3_write.o \ - func.o global.o hash.o \ + fts3_snippet.o fts3_term.o fts3_tokenizer.o fts3_tokenizer1.o \ + fts3_write.o func.o global.o hash.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 \ @@ -194,6 +194,7 @@ SRC += \ $(TOP)/ext/fts3/fts3_icu.c \ $(TOP)/ext/fts3/fts3_porter.c \ $(TOP)/ext/fts3/fts3_snippet.c \ + $(TOP)/ext/fts3/fts3_term.c \ $(TOP)/ext/fts3/fts3_tokenizer.h \ $(TOP)/ext/fts3/fts3_tokenizer.c \ $(TOP)/ext/fts3/fts3_tokenizer1.c \ @@ -483,6 +484,9 @@ fts3_icu.o: $(TOP)/ext/fts3/fts3_icu.c $(HDR) $(EXTHDR) fts3_snippet.o: $(TOP)/ext/fts3/fts3_snippet.c $(HDR) $(EXTHDR) $(TCCX) -DSQLITE_CORE -c $(TOP)/ext/fts3/fts3_snippet.c +fts3_term.o: $(TOP)/ext/fts3/fts3_term.c $(HDR) $(EXTHDR) + $(TCCX) -DSQLITE_CORE -c $(TOP)/ext/fts3/fts3_term.c + fts3_porter.o: $(TOP)/ext/fts3/fts3_porter.c $(HDR) $(EXTHDR) $(TCCX) -DSQLITE_CORE -c $(TOP)/ext/fts3/fts3_porter.c diff --git a/manifest b/manifest index 1415b061f0..87e21c9908 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Add\sfts3_term.c\sto\samalg\sgen\sscript\sand\sconfigure\sinput\sfiles. -D 2011-05-12T21:01:12.782 +C Also\sadd\sfts3_term.c\sto\smain.mk. +D 2011-05-13T17:11:20.942 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 4a7ed220f2e9a068fd0f0b2ec451439f63e629fc F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -102,7 +102,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 496cec8b7890e39127532294e28e5e1d1b1beae1 +F main.mk bedd9fb5f843eab5d575275ef7d906a1e58c30a2 F mkdll.sh 7d09b23c05d56532e9d44a50868eb4b12ff4f74a F mkextu.sh 416f9b7089d80e5590a29692c9d9280a10dbad9f F mkextw.sh 4123480947681d9b434a5e7b1ee08135abe409ac @@ -935,7 +935,7 @@ F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224 F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e F tool/split-sqlite3c.tcl d9be87f1c340285a3e081eb19b4a247981ed290c F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f -P 851ab75d5f5d64d95d6237c28658bbc32145b78b -R f2444b92fe2cfe7d047908f98416ca93 -U shaneh -Z aec7145a879a050a92e29403b1ef0483 +P 6ee0773290a4c4aac2b2b5e1741e65170e08a8bb +R e29a65a14e0a90ae39fc424e77122ad0 +U drh +Z 4626b21df75720896779227cd4b29fbb diff --git a/manifest.uuid b/manifest.uuid index f29a126a22..8352adc09a 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -6ee0773290a4c4aac2b2b5e1741e65170e08a8bb \ No newline at end of file +966f2d2c1f01b6345eab5df87a40d337ced1c087 \ No newline at end of file From 99a66928c21a159697fc09e58ca1b0f1969491a7 Mon Sep 17 00:00:00 2001 From: drh Date: Fri, 13 May 2011 18:51:42 +0000 Subject: [PATCH 28/40] Make arrangements so that virtual table inserts into shadow tables do not modify the sqlite3_last_insert_rowid() return. Document that this is how sqlite3_last_insert_rowid() works. FossilOrigin-Name: e569f18b989aef853c9d71eaf73d6967f0a8c583 --- manifest | 14 +++++++------- manifest.uuid | 2 +- src/sqlite.h.in | 14 +++++++++----- src/vdbe.c | 13 +++++++++---- 4 files changed, 26 insertions(+), 17 deletions(-) diff --git a/manifest b/manifest index 87e21c9908..e52173bba4 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Also\sadd\sfts3_term.c\sto\smain.mk. -D 2011-05-13T17:11:20.942 +C Make\sarrangements\sso\sthat\svirtual\stable\sinserts\sinto\sshadow\stables\sdo\nnot\smodify\sthe\ssqlite3_last_insert_rowid()\sreturn.\s\sDocument\sthat\sthis\nis\show\ssqlite3_last_insert_rowid()\sworks. +D 2011-05-13T18:51:42.945 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 4a7ed220f2e9a068fd0f0b2ec451439f63e629fc F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -179,7 +179,7 @@ F src/resolve.c 1c0f32b64f8e3f555fe1f732f9d6f501a7f05706 F src/rowset.c 69afa95a97c524ba6faf3805e717b5b7ae85a697 F src/select.c d9d440809025a58547e39f4f268c2a296bfb56ff F src/shell.c 72e7e176bf46d5c6518d15ac4ad6847c4bb5df79 -F src/sqlite.h.in 26f123aa6f23b6cbd84d4ef6df3b8210a23a3b0b +F src/sqlite.h.in d7cc9050446a5ed9eb896362dd264e6e10e0cc03 F src/sqlite3ext.h c90bd5507099f62043832d73f6425d8d5c5da754 F src/sqliteInt.h b34bd64a7ade4808fcc301e0bb67ef5051ea49c6 F src/sqliteLimit.h 164b0e6749d31e0daa1a4589a169d31c0dec7b3d @@ -236,7 +236,7 @@ F src/update.c 5bcb56e5c7380a2eecb0e71891dbd4ad7437748f F src/utf.c d83650c3ea08f7407bd9d0839d9885241c209c60 F src/util.c 914e860d21496b19a912cd14f6f7a889a22f44e1 F src/vacuum.c 05513dca036a1e7848fe18d5ed1265ac0b32365e -F src/vdbe.c b2070c926a896e59234e27412a45e261fe752235 +F src/vdbe.c 343a068e8daeb8475e66776feb9f2974046e95c5 F src/vdbe.h 8a675fefdf7119441fe817c800a9a52440c2e797 F src/vdbeInt.h fe8f58d305e629fff02f61f655aca1d299f1f6ae F src/vdbeapi.c e0e2672e0a96ae3f8575c8ecd02912a3e8a554a1 @@ -935,7 +935,7 @@ F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224 F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e F tool/split-sqlite3c.tcl d9be87f1c340285a3e081eb19b4a247981ed290c F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f -P 6ee0773290a4c4aac2b2b5e1741e65170e08a8bb -R e29a65a14e0a90ae39fc424e77122ad0 +P 966f2d2c1f01b6345eab5df87a40d337ced1c087 +R bc50f0e830166d8298c23030a9099063 U drh -Z 4626b21df75720896779227cd4b29fbb +Z 667528c5e659a82acf6d9a2a3fcf251b diff --git a/manifest.uuid b/manifest.uuid index 8352adc09a..033c321dcb 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -966f2d2c1f01b6345eab5df87a40d337ced1c087 \ No newline at end of file +e569f18b989aef853c9d71eaf73d6967f0a8c583 \ No newline at end of file diff --git a/src/sqlite.h.in b/src/sqlite.h.in index 8e041ac750..dbc4a45a6c 100644 --- a/src/sqlite.h.in +++ b/src/sqlite.h.in @@ -1548,13 +1548,17 @@ int sqlite3_extended_result_codes(sqlite3*, int onoff); ** ** ^This routine returns the [rowid] of the most recent ** successful [INSERT] into the database from the [database connection] -** in the first argument. ^If no successful [INSERT]s +** in the first argument. ^As of SQLite version 3.7.7, this routines +** records the last insert rowid of both ordinary tables and [virtual tables]. +** ^If no successful [INSERT]s ** have ever occurred on that database connection, zero is returned. ** -** ^(If an [INSERT] occurs within a trigger, then the [rowid] of the inserted -** row is returned by this routine as long as the trigger is running. -** But once the trigger terminates, the value returned by this routine -** reverts to the last value inserted before the trigger fired.)^ +** ^(If an [INSERT] occurs within a trigger or within a [virtual table] +** method, then this routine will return the [rowid] of the inserted +** row as long as the trigger or virtual table method is running. +** But once the trigger or virtual table method ends, the value returned +** by this routine reverts to what it was before the trigger or virtual +** table method began.)^ ** ** ^An [INSERT] that fails due to a constraint violation is not a ** successful [INSERT] and does not change the value returned by this diff --git a/src/vdbe.c b/src/vdbe.c index c409fdd83b..cac0906998 100644 --- a/src/vdbe.c +++ b/src/vdbe.c @@ -564,6 +564,7 @@ int sqlite3VdbeExec( Mem *pOut = 0; /* Output operand */ int iCompare = 0; /* Result of last OP_Compare operation */ int *aPermute = 0; /* Permutation of columns for OP_Compare */ + i64 lastRowid = db->lastRowid; /* Saved value of the last insert ROWID */ #ifdef VDBE_PROFILE u64 start; /* CPU clock count at start of opcode */ int origPc; /* Program counter at start of opcode */ @@ -833,6 +834,7 @@ case OP_Halt: { p->nFrame--; sqlite3VdbeSetChanges(db, p->nChange); pc = sqlite3VdbeFrameRestore(pFrame); + lastRowid = db->lastRowid; if( pOp->p2==OE_Ignore ){ /* Instruction pc is the OP_Program that invoked the sub-program ** currently being halted. If the p2 instruction of this OP_Halt @@ -1393,7 +1395,9 @@ case OP_Function: { assert( pOp[-1].opcode==OP_CollSeq ); ctx.pColl = pOp[-1].p4.pColl; } + db->lastRowid = lastRowid; (*ctx.pFunc->xFunc)(&ctx, n, apVal); /* IMP: R-24505-23230 */ + lastRowid = db->lastRowid; if( db->mallocFailed ){ /* Even though a malloc() has failed, the implementation of the ** user function may have called an sqlite3_result_XXX() function @@ -3809,7 +3813,7 @@ case OP_NewRowid: { /* out2-prerelease */ assert( pOp->p3==0 ); /* We cannot be in random rowid mode if this is ** an AUTOINCREMENT table. */ /* on the first attempt, simply do one more than previous */ - v = db->lastRowid; + v = lastRowid; v &= (MAX_ROWID>>1); /* ensure doesn't go negative */ v++; /* ensure non-zero */ cnt = 0; @@ -3919,7 +3923,7 @@ case OP_InsertInt: { } if( pOp->p5 & OPFLAG_NCHANGE ) p->nChange++; - if( pOp->p5 & OPFLAG_LASTROWID ) db->lastRowid = iKey; + if( pOp->p5 & OPFLAG_LASTROWID ) db->lastRowid = lastRowid = iKey; if( pData->flags & MEM_Null ){ pData->z = 0; pData->n = 0; @@ -5007,7 +5011,7 @@ case OP_Program: { /* jump */ p->nFrame++; pFrame->pParent = p->pFrame; - pFrame->lastRowid = db->lastRowid; + pFrame->lastRowid = lastRowid; pFrame->nChange = p->nChange; p->nChange = 0; p->pFrame = pFrame; @@ -5814,7 +5818,7 @@ case OP_VUpdate: { importVtabErrMsg(p, pVtab); if( rc==SQLITE_OK && pOp->p1 ){ assert( nArg>1 && apArg[0] && (apArg[0]->flags&MEM_Null) ); - db->lastRowid = rowid; + db->lastRowid = lastRowid = rowid; } if( rc==SQLITE_CONSTRAINT && pOp->p4.pVtab->bConstraint ){ if( pOp->p5==OE_Ignore ){ @@ -5972,6 +5976,7 @@ vdbe_error_halt: ** release the mutexes on btrees that were acquired at the ** top. */ vdbe_return: + db->lastRowid = lastRowid; sqlite3VdbeLeave(p); return rc; From 85a837558066fdf758d19b905e024690076bb09b Mon Sep 17 00:00:00 2001 From: drh Date: Mon, 16 May 2011 21:00:27 +0000 Subject: [PATCH 29/40] Enhance WAL mode so that the WAL file honors the journal size limit set by PRAGMA journal_size_limit. FossilOrigin-Name: db7e500f69faf1906a84991ba67d26a195f02ae5 --- manifest | 17 +++---- manifest.uuid | 2 +- src/pager.c | 4 +- src/wal.c | 26 +++++++++++ src/wal.h | 6 ++- test/wal7.test | 118 +++++++++++++++++++++++++++++++++++++++++++++++++ 6 files changed, 162 insertions(+), 11 deletions(-) create mode 100644 test/wal7.test diff --git a/manifest b/manifest index e52173bba4..4a39930802 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Make\sarrangements\sso\sthat\svirtual\stable\sinserts\sinto\sshadow\stables\sdo\nnot\smodify\sthe\ssqlite3_last_insert_rowid()\sreturn.\s\sDocument\sthat\sthis\nis\show\ssqlite3_last_insert_rowid()\sworks. -D 2011-05-13T18:51:42.945 +C Enhance\sWAL\smode\sso\sthat\sthe\sWAL\sfile\shonors\sthe\sjournal\ssize\slimit\sset\nby\sPRAGMA\sjournal_size_limit. +D 2011-05-16T21:00:27.928 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 4a7ed220f2e9a068fd0f0b2ec451439f63e629fc F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -165,7 +165,7 @@ F src/os_common.h a8f95b81eca8a1ab8593d23e94f8a35f35d4078f F src/os_os2.c 4a75888ba3dfc820ad5e8177025972d74d7f2440 F src/os_unix.c 2c67d126874b78eb427371db4793f0e8fbc7448b F src/os_win.c ff0e14615a5086fa5ba6926e4ec0dc9cfb5a1a84 -F src/pager.c 24b689bc3639d534f5fb292d2c68038b1e720527 +F src/pager.c ebf0411b037fbc6dec272520be55fc11423e789a F src/pager.h 3f8c783de1d4706b40b1ac15b64f5f896bcc78d1 F src/parse.y 12b7ebd61ea54f0e1b1083ff69cc2c8ce9353d58 F src/pcache.c 09d38c44ab275db581f7a2f6ff8b9bc7f8c0faaa @@ -245,8 +245,8 @@ F src/vdbeblob.c c3ccb7c8732858c680f442932e66ad06bb036562 F src/vdbemem.c 0498796b6ffbe45e32960d6a1f5adfb6e419883b F src/vdbetrace.c 5d0dc3d5fd54878cc8d6d28eb41deb8d5885b114 F src/vtab.c 48dcef8bc757c2e7b488f68b5ddebb1650da2450 -F src/wal.c 7334009b396285b658a95a3b6bc6d2b016a1f794 -F src/wal.h 7a5fbb00114b7f2cd40c7e1003d4c41ce9d26840 +F src/wal.c de27c34c8016c00be348fc6bed588816557ceb66 +F src/wal.h 66b40bd91bc29a5be1c88ddd1f5ade8f3f48728a F src/walker.c 3112bb3afe1d85dc52317cb1d752055e9a781f8f F src/where.c 55403ce19c506be6a321c7f129aff693d6103db5 F test/aggerror.test a867e273ef9e3d7919f03ef4f0e8c0d2767944f2 @@ -873,6 +873,7 @@ F test/wal3.test 5c396cc22497244d627306f4c1d360167353f8dd F test/wal4.test 3404b048fa5e10605facaf70384e6d2943412e30 F test/wal5.test 1bbfaa316dc2a1d0d1fac3f4500c38a90055a41b F test/wal6.test 07aa31ca8892d0527f2c5c5a9a2a87aa421dfaa8 +F test/wal7.test 09bc8de3d11949571d6f7a4188b308059cec27e5 F test/wal_common.tcl a98f17fba96206122eff624db0ab13ec377be4fe F test/walbak.test 4df1c7369da0301caeb9a48fa45997fd592380e4 F test/walbig.test e882bc1d014afffbfa2b6ba36e0f07d30a633ad0 @@ -935,7 +936,7 @@ F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224 F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e F tool/split-sqlite3c.tcl d9be87f1c340285a3e081eb19b4a247981ed290c F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f -P 966f2d2c1f01b6345eab5df87a40d337ced1c087 -R bc50f0e830166d8298c23030a9099063 +P e569f18b989aef853c9d71eaf73d6967f0a8c583 +R cf1687694ba42845f8565b086734fa2b U drh -Z 667528c5e659a82acf6d9a2a3fcf251b +Z b788aa40bf13c0a5b33fd90cecbf33e8 diff --git a/manifest.uuid b/manifest.uuid index 033c321dcb..8a54fcea5d 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -e569f18b989aef853c9d71eaf73d6967f0a8c583 \ No newline at end of file +db7e500f69faf1906a84991ba67d26a195f02ae5 \ No newline at end of file diff --git a/src/pager.c b/src/pager.c index 8ad6984f8a..24db850273 100644 --- a/src/pager.c +++ b/src/pager.c @@ -6607,6 +6607,7 @@ int sqlite3PagerOkToChangeJournalMode(Pager *pPager){ i64 sqlite3PagerJournalSizeLimit(Pager *pPager, i64 iLimit){ if( iLimit>=-1 ){ pPager->journalSizeLimit = iLimit; + sqlite3WalLimit(pPager->pWal, iLimit); } return pPager->journalSizeLimit; } @@ -6698,7 +6699,8 @@ static int pagerOpenWal(Pager *pPager){ */ if( rc==SQLITE_OK ){ rc = sqlite3WalOpen(pPager->pVfs, - pPager->fd, pPager->zWal, pPager->exclusiveMode, &pPager->pWal + pPager->fd, pPager->zWal, pPager->exclusiveMode, + pPager->journalSizeLimit, &pPager->pWal ); } diff --git a/src/wal.c b/src/wal.c index 51ea18fb21..1222660985 100644 --- a/src/wal.c +++ b/src/wal.c @@ -412,6 +412,7 @@ struct Wal { sqlite3_file *pDbFd; /* File handle for the database file */ sqlite3_file *pWalFd; /* File handle for WAL file */ u32 iCallback; /* Value to pass to log callback (or 0) */ + i64 mxWalSize; /* Truncate WAL to this size upon reset */ int nWiData; /* Size of array apWiData */ volatile u32 **apWiData; /* Pointer to wal-index content in memory */ u32 szPage; /* Database page size */ @@ -1234,6 +1235,7 @@ int sqlite3WalOpen( sqlite3_file *pDbFd, /* The open database file */ const char *zWalName, /* Name of the WAL file */ int bNoShm, /* True to run in heap-memory mode */ + i64 mxWalSize, /* Truncate WAL to this size on reset */ Wal **ppWal /* OUT: Allocated Wal handle */ ){ int rc; /* Return Code */ @@ -1266,6 +1268,7 @@ int sqlite3WalOpen( pRet->pWalFd = (sqlite3_file *)&pRet[1]; pRet->pDbFd = pDbFd; pRet->readLock = -1; + pRet->mxWalSize = mxWalSize; pRet->zWalName = zWalName; pRet->exclusiveMode = (bNoShm ? WAL_HEAPMEMORY_MODE: WAL_NORMAL_MODE); @@ -1287,6 +1290,13 @@ int sqlite3WalOpen( return rc; } +/* +** Change the size to which the WAL file is trucated on each reset. +*/ +void sqlite3WalLimit(Wal *pWal, i64 iLimit){ + if( pWal ) pWal->mxWalSize = iLimit; +} + /* ** Find the smallest page number out of all pages held in the WAL that ** has not been returned by any prior invocation of this method on the @@ -2522,6 +2532,22 @@ static int walRestartLog(Wal *pWal){ */ int i; /* Loop counter */ u32 *aSalt = pWal->hdr.aSalt; /* Big-endian salt values */ + + /* Limit the size of WAL file if the journal_size_limit PRAGMA is + ** set to a non-negative value. Log errors encountered + ** during the truncation attempt. */ + if( pWal->mxWalSize>=0 ){ + i64 sz; + int rx; + rx = sqlite3OsFileSize(pWal->pWalFd, &sz); + if( rx==SQLITE_OK && (sz > pWal->mxWalSize) ){ + rx = sqlite3OsTruncate(pWal->pWalFd, pWal->mxWalSize); + } + if( rx ){ + sqlite3_log(rx, "cannot limit WAL size: %s", pWal->zWalName); + } + } + pWal->nCkpt++; pWal->hdr.mxFrame = 0; sqlite3Put4byte((u8*)&aSalt[0], 1 + sqlite3Get4byte((u8*)&aSalt[0])); diff --git a/src/wal.h b/src/wal.h index 2039c701cf..a62b23bbdc 100644 --- a/src/wal.h +++ b/src/wal.h @@ -21,6 +21,7 @@ #ifdef SQLITE_OMIT_WAL # define sqlite3WalOpen(x,y,z) 0 +# define sqlite3WalLimit(x,y) # define sqlite3WalClose(w,x,y,z) 0 # define sqlite3WalBeginReadTransaction(y,z) 0 # define sqlite3WalEndReadTransaction(z) @@ -46,9 +47,12 @@ typedef struct Wal Wal; /* Open and close a connection to a write-ahead log. */ -int sqlite3WalOpen(sqlite3_vfs*, sqlite3_file*, const char *zName, int, Wal**); +int sqlite3WalOpen(sqlite3_vfs*, sqlite3_file*, const char *, int, i64, Wal**); int sqlite3WalClose(Wal *pWal, int sync_flags, int, u8 *); +/* Set the limiting size of a WAL file. */ +void sqlite3WalLimit(Wal*, i64); + /* Used by readers to open (lock) and close (unlock) a snapshot. A ** snapshot is like a read-transaction. It is the state of the database ** at an instant in time. sqlite3WalOpenSnapshot gets a read lock and diff --git a/test/wal7.test b/test/wal7.test new file mode 100644 index 0000000000..cfe2d7b8b0 --- /dev/null +++ b/test/wal7.test @@ -0,0 +1,118 @@ +# 2011 May 16 +# +# The author disclaims copyright to this source code. In place of +# a legal notice, here is a blessing: +# +# May you do good and not evil. +# May you find forgiveness for yourself and forgive others. +# May you share freely, never taking more than you give. +# +#*********************************************************************** +# This file implements regression tests for SQLite library. The +# focus of this file is testing the PRAGMA journal_size_limit when +# in WAL mode. +# + +set testdir [file dirname $argv0] +source $testdir/tester.tcl +ifcapable !wal {finish_test ; return } + +# Case 1: No size limit. Journal can get large. +# +do_test wal7-1.0 { + db close + forcedelete test.db + sqlite3 db test.db + db eval { + PRAGMA page_size=1024; + PRAGMA journal_mode=WAL; + PRAGMA wal_autocheckpoint=50; -- 50 pages + CREATE TABLE t1(x, y UNIQUE); + INSERT INTO t1 VALUES(1,2); + INSERT INTO t1 VALUES(zeroblob(200000),4); + CREATE TABLE t2(z); + DELETE FROM t1; + INSERT INTO t2 SELECT x FROM t1; + } + expr {[file size test.db-wal]>50*1100} +} 1 +do_test wal7-1.1 { + db eval {PRAGMA wal_checkpoint} + expr {[file size test.db-wal]>50*1100} +} 1 +do_test wal7-1.2 { + db eval {INSERT INTO t2 VALUES('hi');} + expr {[file size test.db-wal]>50*1100} +} 1 + +# Case 2: Size limit at half the autocheckpoint size. +# +do_test wal7-2.0 { + db close + forcedelete test.db + sqlite3 db test.db + db eval { + PRAGMA page_size=1024; + PRAGMA journal_mode=WAL; + PRAGMA wal_autocheckpoint=50; -- 50 pages + PRAGMA journal_size_limit=25000; + CREATE TABLE t1(x, y UNIQUE); + INSERT INTO t1 VALUES(1,2); + INSERT INTO t1 VALUES(zeroblob(200000),4); + CREATE TABLE t2(z); + DELETE FROM t1; + INSERT INTO t2 SELECT x FROM t1; + } + file size test.db-wal +} 25000 + + +# Case 3: Size limit of zero. +# +do_test wal7-3.0 { + db close + forcedelete test.db + sqlite3 db test.db + db eval { + PRAGMA page_size=1024; + PRAGMA journal_mode=WAL; + PRAGMA wal_autocheckpoint=50; -- 50 pages + PRAGMA journal_size_limit=0; + CREATE TABLE t1(x, y UNIQUE); + INSERT INTO t1 VALUES(1,2); + INSERT INTO t1 VALUES(zeroblob(200000),4); + CREATE TABLE t2(z); + DELETE FROM t1; + INSERT INTO t2 SELECT x FROM t1; + } + set sz [file size test.db-wal] + expr {$sz>0 && $sz<10000} +} 1 + + +# Case 4: Size limit set before going WAL +# +do_test wal7-4.0 { + db close + forcedelete test.db + sqlite3 db test.db + db eval { + PRAGMA page_size=1024; + PRAGMA journal_size_limit=25000; + PRAGMA journal_mode=WAL; + PRAGMA wal_autocheckpoint=50; -- 50 pages + CREATE TABLE t1(x, y UNIQUE); + INSERT INTO t1 VALUES(1,2); + INSERT INTO t1 VALUES(zeroblob(200000),4); + CREATE TABLE t2(z); + DELETE FROM t1; + INSERT INTO t2 SELECT x FROM t1; + } + set sz [file size test.db-wal] +} 25000 + + + + + +finish_test From 807d0fcabaf60274201cbc306b70bf93ba4f78b1 Mon Sep 17 00:00:00 2001 From: dan Date: Tue, 17 May 2011 14:41:36 +0000 Subject: [PATCH 30/40] Avoid including fts3_term.c in the amalgamation, as it contains test code only. FossilOrigin-Name: f392b7ae0266b4c694836583cb91b10f2b6c0752 --- Makefile.in | 9 +++------ ext/fts3/fts3Int.h | 1 + main.mk | 6 +----- manifest | 20 ++++++++++---------- manifest.uuid | 2 +- tool/mksqlite3c.tcl | 1 - 6 files changed, 16 insertions(+), 23 deletions(-) diff --git a/Makefile.in b/Makefile.in index 01c4010b8e..b0871ad940 100644 --- a/Makefile.in +++ b/Makefile.in @@ -166,7 +166,7 @@ LIBOBJS0 = alter.lo analyze.lo attach.lo auth.lo \ callback.lo complete.lo ctime.lo date.lo delete.lo \ expr.lo fault.lo fkey.lo \ fts3.lo fts3_aux.lo fts3_expr.lo fts3_hash.lo fts3_icu.lo fts3_porter.lo \ - fts3_snippet.lo fts3_term.lo fts3_tokenizer.lo fts3_tokenizer1.lo fts3_write.lo \ + fts3_snippet.lo fts3_tokenizer.lo fts3_tokenizer1.lo fts3_write.lo \ func.lo global.lo hash.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 \ @@ -313,7 +313,6 @@ SRC += \ $(TOP)/ext/fts3/fts3_icu.c \ $(TOP)/ext/fts3/fts3_porter.c \ $(TOP)/ext/fts3/fts3_snippet.c \ - $(TOP)/ext/fts3/fts3_term.c \ $(TOP)/ext/fts3/fts3_tokenizer.h \ $(TOP)/ext/fts3/fts3_tokenizer.c \ $(TOP)/ext/fts3/fts3_tokenizer1.c \ @@ -379,7 +378,8 @@ TESTSRC = \ $(TOP)/src/test_thread.c \ $(TOP)/src/test_vfs.c \ $(TOP)/src/test_wholenumber.c \ - $(TOP)/src/test_wsd.c + $(TOP)/src/test_wsd.c \ + $(TOP)/ext/fts3/fts3_term.c # Source code to the library files needed by the test fixture # @@ -836,9 +836,6 @@ fts3_porter.lo: $(TOP)/ext/fts3/fts3_porter.c $(HDR) $(EXTHDR) fts3_snippet.lo: $(TOP)/ext/fts3/fts3_snippet.c $(HDR) $(EXTHDR) $(LTCOMPILE) -DSQLITE_CORE -c $(TOP)/ext/fts3/fts3_snippet.c -fts3_term.lo: $(TOP)/ext/fts3/fts3_term.c $(HDR) $(EXTHDR) - $(LTCOMPILE) -DSQLITE_CORE -c $(TOP)/ext/fts3/fts3_term.c - fts3_tokenizer.lo: $(TOP)/ext/fts3/fts3_tokenizer.c $(HDR) $(EXTHDR) $(LTCOMPILE) -DSQLITE_CORE -c $(TOP)/ext/fts3/fts3_tokenizer.c diff --git a/ext/fts3/fts3Int.h b/ext/fts3/fts3Int.h index b843fe9dc6..8d1e15737d 100644 --- a/ext/fts3/fts3Int.h +++ b/ext/fts3/fts3Int.h @@ -381,6 +381,7 @@ int sqlite3Fts3ExprParse(sqlite3_tokenizer *, void sqlite3Fts3ExprFree(Fts3Expr *); #ifdef SQLITE_TEST int sqlite3Fts3ExprInitTestInterface(sqlite3 *db); +int sqlite3Fts3InitTerm(sqlite3 *db); #endif /* fts3_aux.c */ diff --git a/main.mk b/main.mk index 0035743003..f84e0dea8b 100644 --- a/main.mk +++ b/main.mk @@ -54,7 +54,7 @@ LIBOBJ+= alter.o analyze.o attach.o auth.o \ backup.o bitvec.o btmutex.o btree.o build.o \ callback.o complete.o ctime.o date.o delete.o expr.o fault.o fkey.o \ fts3.o fts3_aux.o fts3_expr.o fts3_hash.o fts3_icu.o fts3_porter.o \ - fts3_snippet.o fts3_term.o fts3_tokenizer.o fts3_tokenizer1.o \ + fts3_snippet.o fts3_tokenizer.o fts3_tokenizer1.o \ fts3_write.o func.o global.o hash.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 \ @@ -194,7 +194,6 @@ SRC += \ $(TOP)/ext/fts3/fts3_icu.c \ $(TOP)/ext/fts3/fts3_porter.c \ $(TOP)/ext/fts3/fts3_snippet.c \ - $(TOP)/ext/fts3/fts3_term.c \ $(TOP)/ext/fts3/fts3_tokenizer.h \ $(TOP)/ext/fts3/fts3_tokenizer.c \ $(TOP)/ext/fts3/fts3_tokenizer1.c \ @@ -484,9 +483,6 @@ fts3_icu.o: $(TOP)/ext/fts3/fts3_icu.c $(HDR) $(EXTHDR) fts3_snippet.o: $(TOP)/ext/fts3/fts3_snippet.c $(HDR) $(EXTHDR) $(TCCX) -DSQLITE_CORE -c $(TOP)/ext/fts3/fts3_snippet.c -fts3_term.o: $(TOP)/ext/fts3/fts3_term.c $(HDR) $(EXTHDR) - $(TCCX) -DSQLITE_CORE -c $(TOP)/ext/fts3/fts3_term.c - fts3_porter.o: $(TOP)/ext/fts3/fts3_porter.c $(HDR) $(EXTHDR) $(TCCX) -DSQLITE_CORE -c $(TOP)/ext/fts3/fts3_porter.c diff --git a/manifest b/manifest index 4a39930802..5d38b63563 100644 --- a/manifest +++ b/manifest @@ -1,7 +1,7 @@ -C Enhance\sWAL\smode\sso\sthat\sthe\sWAL\sfile\shonors\sthe\sjournal\ssize\slimit\sset\nby\sPRAGMA\sjournal_size_limit. -D 2011-05-16T21:00:27.928 +C Avoid\sincluding\sfts3_term.c\sin\sthe\samalgamation,\sas\sit\scontains\stest\scode\sonly. +D 2011-05-17T14:41:36.521 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f -F Makefile.in 4a7ed220f2e9a068fd0f0b2ec451439f63e629fc +F Makefile.in 11dcc00a8d0e5202def00e81732784fb0cc4fe1d F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 F Makefile.vxworks c85ec1d8597fe2f7bc225af12ac1666e21379151 F README cd04a36fbc7ea56932a4052d7d0b7f09f27c33d6 @@ -63,7 +63,7 @@ F ext/fts3/README.tokenizers 998756696647400de63d5ba60e9655036cb966e9 F ext/fts3/README.txt 8c18f41574404623b76917b9da66fcb0ab38328d F ext/fts3/fts3.c 0077bd07395d2aabafa1ed1b104552619ecad34a F ext/fts3/fts3.h 3a10a0af180d502cecc50df77b1b22df142817fe -F ext/fts3/fts3Int.h 8c2ac39ee17362571c58ab2c4f0667324c31f738 +F ext/fts3/fts3Int.h 05d145152620e7849c452bd919f2cc3e2d75309f F ext/fts3/fts3_aux.c 9e931f55eed8498dafe7bc1160f10cbb1a652fdf F ext/fts3/fts3_expr.c 5f49e0deaf723724b08100bb3ff40aab02ad0c93 F ext/fts3/fts3_hash.c 3c8f6387a4a7f5305588b203fa7c887d753e1f1c @@ -102,7 +102,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 bedd9fb5f843eab5d575275ef7d906a1e58c30a2 +F main.mk 6111163d4e9720e4212ef288e967b4aa2c2ce379 F mkdll.sh 7d09b23c05d56532e9d44a50868eb4b12ff4f74a F mkextu.sh 416f9b7089d80e5590a29692c9d9280a10dbad9f F mkextw.sh 4123480947681d9b434a5e7b1ee08135abe409ac @@ -911,7 +911,7 @@ F tool/lempar.c 01ca97f87610d1dac6d8cd96ab109ab1130e76dc F tool/mkkeywordhash.c d2e6b4a5965e23afb80fbe74bb54648cd371f309 F tool/mkopts.tcl 66ac10d240cc6e86abd37dc908d50382f84ff46e F tool/mkspeedsql.tcl a1a334d288f7adfe6e996f2e712becf076745c97 -F tool/mksqlite3c.tcl d171512b785283690b6f80997bee974c80087a23 +F tool/mksqlite3c.tcl 623e26cc8c83322e4151d3ad85ac69d41221bae8 F tool/mksqlite3h.tcl d76c226a5e8e1f3b5f6593bcabe5e98b3b1ec9ff F tool/mksqlite3internalh.tcl 7b43894e21bcb1bb39e11547ce7e38a063357e87 F tool/omittest.tcl b1dd290c1596e0f31fd335160a74ec5dfea3df4a @@ -936,7 +936,7 @@ F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224 F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e F tool/split-sqlite3c.tcl d9be87f1c340285a3e081eb19b4a247981ed290c F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f -P e569f18b989aef853c9d71eaf73d6967f0a8c583 -R cf1687694ba42845f8565b086734fa2b -U drh -Z b788aa40bf13c0a5b33fd90cecbf33e8 +P db7e500f69faf1906a84991ba67d26a195f02ae5 +R ae580e6a17ad522b073057ba8349f079 +U dan +Z c7b8c78d63b81a588c33ebb0305a0680 diff --git a/manifest.uuid b/manifest.uuid index 8a54fcea5d..608d6308f7 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -db7e500f69faf1906a84991ba67d26a195f02ae5 \ No newline at end of file +f392b7ae0266b4c694836583cb91b10f2b6c0752 \ No newline at end of file diff --git a/tool/mksqlite3c.tcl b/tool/mksqlite3c.tcl index f88ca08887..fa99f2df7b 100644 --- a/tool/mksqlite3c.tcl +++ b/tool/mksqlite3c.tcl @@ -298,7 +298,6 @@ foreach file { fts3_expr.c fts3_hash.c fts3_porter.c - fts3_term.c fts3_tokenizer.c fts3_tokenizer1.c fts3_write.c From fc24373999eacec97d42a9148affd6a3b52c33c0 Mon Sep 17 00:00:00 2001 From: drh Date: Tue, 17 May 2011 15:21:56 +0000 Subject: [PATCH 31/40] Avoid exceeding array bounds when reading a corrupt database file in autovacuum mode. Fixes a problem discovered by John Regehr and Peng Li using a customized clang compiler. FossilOrigin-Name: f7c525f5fc31e909721df2b1e66fc62dfb105718 --- manifest | 14 +++++++------- manifest.uuid | 2 +- src/btree.c | 6 ++++++ 3 files changed, 14 insertions(+), 8 deletions(-) diff --git a/manifest b/manifest index 5d38b63563..0cb8889843 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Avoid\sincluding\sfts3_term.c\sin\sthe\samalgamation,\sas\sit\scontains\stest\scode\sonly. -D 2011-05-17T14:41:36.521 +C Avoid\sexceeding\sarray\sbounds\swhen\sreading\sa\scorrupt\sdatabase\sfile\sin\nautovacuum\smode.\s\sFixes\sa\sproblem\sdiscovered\sby\sJohn\sRegehr\sand\sPeng\sLi\nusing\sa\scustomized\sclang\scompiler. +D 2011-05-17T15:21:56.657 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 11dcc00a8d0e5202def00e81732784fb0cc4fe1d F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -122,7 +122,7 @@ F src/auth.c 523da7fb4979469955d822ff9298352d6b31de34 F src/backup.c 986c15232757f2873dff35ee3b35cbf935fc573c F src/bitvec.c af50f1c8c0ff54d6bdb7a80e2fceca5a93670bef F src/btmutex.c 976f45a12e37293e32cae0281b15a21d48a8aaa7 -F src/btree.c 26f8a9d6169413c5682b89b5397d20437b653154 +F src/btree.c 975ad691a57eb1fb60f1ec76ad0b6571eace62f9 F src/btree.h f5d775cd6cfc7ac32a2535b70e8d2af48ef5f2ce F src/btreeInt.h 67978c014fa4f7cc874032dd3aacadd8db656bc3 F src/build.c 0132bc6631fa617a1d28ef805921f6dbac18a514 @@ -936,7 +936,7 @@ F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224 F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e F tool/split-sqlite3c.tcl d9be87f1c340285a3e081eb19b4a247981ed290c F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f -P db7e500f69faf1906a84991ba67d26a195f02ae5 -R ae580e6a17ad522b073057ba8349f079 -U dan -Z c7b8c78d63b81a588c33ebb0305a0680 +P f392b7ae0266b4c694836583cb91b10f2b6c0752 +R cf53219bce3a7dbccc0e0612301125fc +U drh +Z 6f0c0bbdb12e972d7467056dbeea9264 diff --git a/manifest.uuid b/manifest.uuid index 608d6308f7..7f322c90bc 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -f392b7ae0266b4c694836583cb91b10f2b6c0752 \ No newline at end of file +f7c525f5fc31e909721df2b1e66fc62dfb105718 \ No newline at end of file diff --git a/src/btree.c b/src/btree.c index d021893241..df75053743 100644 --- a/src/btree.c +++ b/src/btree.c @@ -788,6 +788,7 @@ static void ptrmapPut(BtShared *pBt, Pgno key, u8 eType, Pgno parent, int *pRC){ *pRC = SQLITE_CORRUPT_BKPT; goto ptrmap_exit; } + assert( offset <= (int)pBt->usableSize-5 ); pPtrmap = (u8 *)sqlite3PagerGetData(pDbPage); if( eType!=pPtrmap[offset] || get4byte(&pPtrmap[offset+1])!=parent ){ @@ -827,6 +828,11 @@ static int ptrmapGet(BtShared *pBt, Pgno key, u8 *pEType, Pgno *pPgno){ pPtrmap = (u8 *)sqlite3PagerGetData(pDbPage); offset = PTRMAP_PTROFFSET(iPtrmap, key); + if( offset<0 ){ + sqlite3PagerUnref(pDbPage); + return SQLITE_CORRUPT_BKPT; + } + assert( offset <= (int)pBt->usableSize-5 ); assert( pEType!=0 ); *pEType = pPtrmap[offset]; if( pPgno ) *pPgno = get4byte(&pPtrmap[offset+1]); From 133d7dab17f1a82fbbfa7f0710b6c2dc008d9407 Mon Sep 17 00:00:00 2001 From: dan Date: Tue, 17 May 2011 15:56:16 +0000 Subject: [PATCH 32/40] Add extended return code SQLITE_CORRUPT_VTAB. Returned when the tcontents of the sqlite tables used internally by a virtual table module are invalid or inconsistent. FossilOrigin-Name: 8844e8bfb87314fb40ecb92705e8fff88f72bb38 --- ext/fts3/fts3.c | 6 +++--- ext/fts3/fts3_snippet.c | 4 ++-- ext/fts3/fts3_write.c | 10 +++++----- ext/rtree/rtree.c | 14 +++++++------- manifest | 26 +++++++++++++------------- manifest.uuid | 2 +- src/sqlite.h.in | 1 + src/test1.c | 2 ++ test/fts3corrupt.test | 7 +++++++ 9 files changed, 41 insertions(+), 31 deletions(-) diff --git a/ext/fts3/fts3.c b/ext/fts3/fts3.c index 5a46983d55..ea430627cd 100644 --- a/ext/fts3/fts3.c +++ b/ext/fts3/fts3.c @@ -1195,7 +1195,7 @@ static int fts3CursorSeek(sqlite3_context *pContext, Fts3Cursor *pCsr){ ** table is missing a row that is present in the full-text index. ** The data structures are corrupt. */ - rc = SQLITE_CORRUPT; + rc = SQLITE_CORRUPT_VTAB; } pCsr->isEof = 1; if( pContext ){ @@ -1255,7 +1255,7 @@ static int fts3ScanInteriorNode( zCsr += sqlite3Fts3GetVarint(zCsr, &iChild); zCsr += sqlite3Fts3GetVarint(zCsr, &iChild); if( zCsr>zEnd ){ - return SQLITE_CORRUPT; + return SQLITE_CORRUPT_VTAB; } while( zCsrzEnd ){ - rc = SQLITE_CORRUPT; + rc = SQLITE_CORRUPT_VTAB; goto finish_scan; } if( nPrefix+nSuffix>nAlloc ){ diff --git a/ext/fts3/fts3_snippet.c b/ext/fts3/fts3_snippet.c index 99f9dd7174..8bf9ed2d5a 100644 --- a/ext/fts3/fts3_snippet.c +++ b/ext/fts3/fts3_snippet.c @@ -960,7 +960,7 @@ static int fts3MatchinfoSelectDoctotal( a = sqlite3_column_blob(pStmt, 0); a += sqlite3Fts3GetVarint(a, &nDoc); - if( nDoc==0 ) return SQLITE_CORRUPT; + if( nDoc==0 ) return SQLITE_CORRUPT_VTAB; *pnDoc = (u32)nDoc; if( paLen ) *paLen = a; @@ -1555,7 +1555,7 @@ void sqlite3Fts3Offsets( ); rc = fts3StringAppend(&res, aBuffer, -1); }else if( rc==SQLITE_DONE ){ - rc = SQLITE_CORRUPT; + rc = SQLITE_CORRUPT_VTAB; } } } diff --git a/ext/fts3/fts3_write.c b/ext/fts3/fts3_write.c index 025fb64a64..d00632a75d 100644 --- a/ext/fts3/fts3_write.c +++ b/ext/fts3/fts3_write.c @@ -291,7 +291,7 @@ static int fts3SelectDocsize( rc = sqlite3_step(pStmt); if( rc!=SQLITE_ROW || sqlite3_column_type(pStmt, 0)!=SQLITE_BLOB ){ rc = sqlite3_reset(pStmt); - if( rc==SQLITE_OK ) rc = SQLITE_CORRUPT; + if( rc==SQLITE_OK ) rc = SQLITE_CORRUPT_VTAB; pStmt = 0; }else{ rc = SQLITE_OK; @@ -972,7 +972,7 @@ static int fts3SegReaderNext(Fts3Table *p, Fts3SegReader *pReader){ if( nPrefix<0 || nSuffix<=0 || &pNext[nSuffix]>&pReader->aNode[pReader->nNode] ){ - return SQLITE_CORRUPT; + return SQLITE_CORRUPT_VTAB; } if( nPrefix+nSuffix>pReader->nTermAlloc ){ @@ -998,7 +998,7 @@ static int fts3SegReaderNext(Fts3Table *p, Fts3SegReader *pReader){ if( &pReader->aDoclist[pReader->nDoclist]>&pReader->aNode[pReader->nNode] || pReader->aDoclist[pReader->nDoclist-1] ){ - return SQLITE_CORRUPT; + return SQLITE_CORRUPT_VTAB; } return SQLITE_OK; } @@ -1123,7 +1123,7 @@ int sqlite3Fts3SegReaderCost( } if( nDoc==0 || nByte==0 ){ sqlite3_reset(pStmt); - return SQLITE_CORRUPT; + return SQLITE_CORRUPT_VTAB; } pCsr->nRowAvg = (int)(((nByte / nDoc) + pgsz) / pgsz); @@ -2762,7 +2762,7 @@ int sqlite3Fts3UpdateMethod( if( nArg>1 && rc==SQLITE_OK ){ if( bInsertDone==0 ){ rc = fts3InsertData(p, apVal, pRowid); - if( rc==SQLITE_CONSTRAINT ) rc = SQLITE_CORRUPT; + if( rc==SQLITE_CONSTRAINT ) rc = SQLITE_CORRUPT_VTAB; } if( rc==SQLITE_OK && (!isRemove || *pRowid!=iRemove) ){ rc = fts3PendingTermsDocid(p, *pRowid); diff --git a/ext/rtree/rtree.c b/ext/rtree/rtree.c index 4529f3aabb..6e00827b46 100644 --- a/ext/rtree/rtree.c +++ b/ext/rtree/rtree.c @@ -517,17 +517,17 @@ nodeAcquire( if( pNode && iNode==1 ){ pRtree->iDepth = readInt16(pNode->zData); if( pRtree->iDepth>RTREE_MAX_DEPTH ){ - rc = SQLITE_CORRUPT; + rc = SQLITE_CORRUPT_VTAB; } } /* If no error has occurred so far, check if the "number of entries" ** field on the node is too large. If so, set the return code to - ** SQLITE_CORRUPT. + ** SQLITE_CORRUPT_VTAB. */ if( pNode && rc==SQLITE_OK ){ if( NCELL(pNode)>((pRtree->iNodeSize-4)/pRtree->nBytesPerCell) ){ - rc = SQLITE_CORRUPT; + rc = SQLITE_CORRUPT_VTAB; } } @@ -535,7 +535,7 @@ nodeAcquire( if( pNode!=0 ){ nodeHashInsert(pRtree, pNode); }else{ - rc = SQLITE_CORRUPT; + rc = SQLITE_CORRUPT_VTAB; } *ppNode = pNode; }else{ @@ -1062,7 +1062,7 @@ static int nodeRowidIndex( return SQLITE_OK; } } - return SQLITE_CORRUPT; + return SQLITE_CORRUPT_VTAB; } /* @@ -1657,7 +1657,7 @@ static int AdjustTree( int iCell; if( nodeParentIndex(pRtree, p, &iCell) ){ - return SQLITE_CORRUPT; + return SQLITE_CORRUPT_VTAB; } nodeGetCell(pRtree, pParent, iCell, &cell); @@ -2329,7 +2329,7 @@ static int fixLeafParent(Rtree *pRtree, RtreeNode *pLeaf){ } rc = sqlite3_reset(pRtree->pReadParent); if( rc==SQLITE_OK ) rc = rc2; - if( rc==SQLITE_OK && !pChild->pParent ) rc = SQLITE_CORRUPT; + if( rc==SQLITE_OK && !pChild->pParent ) rc = SQLITE_CORRUPT_VTAB; pChild = pChild->pParent; } return rc; diff --git a/manifest b/manifest index 0cb8889843..ab1aadca4c 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Avoid\sexceeding\sarray\sbounds\swhen\sreading\sa\scorrupt\sdatabase\sfile\sin\nautovacuum\smode.\s\sFixes\sa\sproblem\sdiscovered\sby\sJohn\sRegehr\sand\sPeng\sLi\nusing\sa\scustomized\sclang\scompiler. -D 2011-05-17T15:21:56.657 +C Add\sextended\sreturn\scode\sSQLITE_CORRUPT_VTAB.\sReturned\swhen\sthe\stcontents\sof\sthe\ssqlite\stables\sused\sinternally\sby\sa\svirtual\stable\smodule\sare\sinvalid\sor\sinconsistent. +D 2011-05-17T15:56:16.473 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 11dcc00a8d0e5202def00e81732784fb0cc4fe1d F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -61,7 +61,7 @@ F ext/fts2/mkfts2amal.tcl 974d5d438cb3f7c4a652639262f82418c1e4cff0 F ext/fts3/README.syntax a19711dc5458c20734b8e485e75fb1981ec2427a F ext/fts3/README.tokenizers 998756696647400de63d5ba60e9655036cb966e9 F ext/fts3/README.txt 8c18f41574404623b76917b9da66fcb0ab38328d -F ext/fts3/fts3.c 0077bd07395d2aabafa1ed1b104552619ecad34a +F ext/fts3/fts3.c 18c2a079ba2b9154b7485fd39d1a6d12b5872a76 F ext/fts3/fts3.h 3a10a0af180d502cecc50df77b1b22df142817fe F ext/fts3/fts3Int.h 05d145152620e7849c452bd919f2cc3e2d75309f F ext/fts3/fts3_aux.c 9e931f55eed8498dafe7bc1160f10cbb1a652fdf @@ -70,19 +70,19 @@ F ext/fts3/fts3_hash.c 3c8f6387a4a7f5305588b203fa7c887d753e1f1c F ext/fts3/fts3_hash.h 8331fb2206c609f9fc4c4735b9ab5ad6137c88ec F ext/fts3/fts3_icu.c ac494aed69835008185299315403044664bda295 F ext/fts3/fts3_porter.c d61cfd81fb0fd8fbcb25adcaee0ba671aefaa5c2 -F ext/fts3/fts3_snippet.c a4a3c7d2ab15ca9188e2d9b51a5e3927bf76580d +F ext/fts3/fts3_snippet.c 92b40397b28422c35c4127492d7ac6da34d1966a F ext/fts3/fts3_term.c f115f5a5f4298303d3b22fc6c524b8d565c7b950 F ext/fts3/fts3_tokenizer.c 055f3dc7369585350b28db1ee0f3b214dca6724d F ext/fts3/fts3_tokenizer.h 13ffd9fcb397fec32a05ef5cd9e0fa659bf3dbd3 F ext/fts3/fts3_tokenizer1.c 6e5cbaa588924ac578263a598e4fb9f5c9bb179d -F ext/fts3/fts3_write.c 7d6d904b89333448eb968fc82470a74985d0b61e +F ext/fts3/fts3_write.c b50181e5ecf484c2f56e98d651424e4b69f96c89 F ext/fts3/fts3speed.tcl b54caf6a18d38174f1a6e84219950d85e98bb1e9 F ext/fts3/mkfts3amal.tcl 252ecb7fe6467854f2aa237bf2c390b74e71f100 F ext/icu/README.txt bf8461d8cdc6b8f514c080e4e10dc3b2bbdfefa9 F ext/icu/icu.c eb9ae1d79046bd7871aa97ee6da51eb770134b5a F ext/icu/sqliteicu.h 728867a802baa5a96de7495e9689a8e01715ef37 F ext/rtree/README 6315c0d73ebf0ec40dedb5aa0e942bc8b54e3761 -F ext/rtree/rtree.c 829c6901a2b065ff93a68d431f9eaba8de7128e0 +F ext/rtree/rtree.c 2445bec932f58f8f4fe9de49a63bd6bf24db82d6 F ext/rtree/rtree.h 834dbcb82dc85b2481cde6a07cdadfddc99e9b9e F ext/rtree/rtree1.test 28e1b8da4da98093ce3210187434dd760a8d89d8 F ext/rtree/rtree2.test acbb3a4ce0f4fbc2c304d2b4b784cfa161856bba @@ -179,14 +179,14 @@ F src/resolve.c 1c0f32b64f8e3f555fe1f732f9d6f501a7f05706 F src/rowset.c 69afa95a97c524ba6faf3805e717b5b7ae85a697 F src/select.c d9d440809025a58547e39f4f268c2a296bfb56ff F src/shell.c 72e7e176bf46d5c6518d15ac4ad6847c4bb5df79 -F src/sqlite.h.in d7cc9050446a5ed9eb896362dd264e6e10e0cc03 +F src/sqlite.h.in ee13c23409219c0a5fd3f0c0cd761a5073564a0b F src/sqlite3ext.h c90bd5507099f62043832d73f6425d8d5c5da754 F src/sqliteInt.h b34bd64a7ade4808fcc301e0bb67ef5051ea49c6 F src/sqliteLimit.h 164b0e6749d31e0daa1a4589a169d31c0dec7b3d F src/status.c 7ac64842c86cec2fc1a1d0e5c16d3beb8ad332bf F src/table.c 2cd62736f845d82200acfa1287e33feb3c15d62e F src/tclsqlite.c 501c9a200fd998a268be475be5858febc90b725b -F src/test1.c f506164085bc4cbbb4b5c14b9c6de153f1aeafc5 +F src/test1.c 4a1171af201be90c21d64a872e686b1333d9a2cf F src/test2.c 80d323d11e909cf0eb1b6fbb4ac22276483bcf31 F src/test3.c 124ff9735fb6bb7d41de180d6bac90e7b1509432 F src/test4.c d1e5a5e904d4b444cf572391fdcb017638e36ff7 @@ -458,7 +458,7 @@ F test/fts3b.test e93bbb653e52afde110ad53bbd793f14fe7a8984 F test/fts3c.test fc723a9cf10b397fdfc2b32e73c53c8b1ec02958 F test/fts3comp1.test a0f5b16a2df44dd0b15751787130af2183167c0c F test/fts3conf.test 8e65ea56f88ced6cdd2252bdddb1a8327ae5af7e -F test/fts3corrupt.test 7890cc202406858386ddf390a879dcf80bc10abf +F test/fts3corrupt.test 7b0f91780ca36118d73324ec803187208ad33b32 F test/fts3corrupt2.test 6d96efae2f8a6af3eeaf283aba437e6d0e5447ba F test/fts3cov.test e0fb00d8b715ddae4a94c305992dfc3ef70353d7 F test/fts3d.test 95fb3c862cbc4297c93fceb9a635543744e9ef52 @@ -936,7 +936,7 @@ F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224 F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e F tool/split-sqlite3c.tcl d9be87f1c340285a3e081eb19b4a247981ed290c F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f -P f392b7ae0266b4c694836583cb91b10f2b6c0752 -R cf53219bce3a7dbccc0e0612301125fc -U drh -Z 6f0c0bbdb12e972d7467056dbeea9264 +P f7c525f5fc31e909721df2b1e66fc62dfb105718 +R 8174cc733f5a883825d78ae2804a3f2d +U dan +Z 5f2d01dc50656b115009ed665e1773e1 diff --git a/manifest.uuid b/manifest.uuid index 7f322c90bc..a4856a4e02 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -f7c525f5fc31e909721df2b1e66fc62dfb105718 \ No newline at end of file +8844e8bfb87314fb40ecb92705e8fff88f72bb38 \ No newline at end of file diff --git a/src/sqlite.h.in b/src/sqlite.h.in index dbc4a45a6c..4bcba18a95 100644 --- a/src/sqlite.h.in +++ b/src/sqlite.h.in @@ -453,6 +453,7 @@ int sqlite3_exec( #define SQLITE_LOCKED_SHAREDCACHE (SQLITE_LOCKED | (1<<8)) #define SQLITE_BUSY_RECOVERY (SQLITE_BUSY | (1<<8)) #define SQLITE_CANTOPEN_NOTEMPDIR (SQLITE_CANTOPEN | (1<<8)) +#define SQLITE_CORRUPT_VTAB (SQLITE_CORRUPT | (1<<8)) /* ** CAPI3REF: Flags For File Open Operations diff --git a/src/test1.c b/src/test1.c index 8e30123433..50575afbbc 100644 --- a/src/test1.c +++ b/src/test1.c @@ -163,6 +163,8 @@ const char *sqlite3TestErrorName(int rc){ case SQLITE_IOERR_CHECKRESERVEDLOCK: zName = "SQLITE_IOERR_CHECKRESERVEDLOCK"; break; case SQLITE_IOERR_LOCK: zName = "SQLITE_IOERR_LOCK"; break; + case SQLITE_CORRUPT_VTAB: zName = "SQLITE_CORRUPT_VTAB"; break; + zName = "SQLITE_IOERR_CHECKRESERVEDLOCK"; break; default: zName = "SQLITE_Unknown"; break; } return zName; diff --git a/test/fts3corrupt.test b/test/fts3corrupt.test index b8b45c3951..ea4c9a9d3b 100644 --- a/test/fts3corrupt.test +++ b/test/fts3corrupt.test @@ -40,6 +40,7 @@ do_test fts3corrupt-1.2 { do_catchsql_test 1.3 { INSERT INTO t1 VALUES('world'); } {1 {database disk image is malformed}} +do_test 1.3.1 { sqlite3_extended_errcode db } SQLITE_CORRUPT_VTAB do_execsql_test 1.4 { DROP TABLE t1; } @@ -69,6 +70,7 @@ do_test fts3corrupt-2.1 { do_catchsql_test 2.2 { SELECT rowid FROM t1 WHERE t1 MATCH 'hello' } {1 {database disk image is malformed}} +do_test 2.2.1 { sqlite3_extended_errcode db } SQLITE_CORRUPT_VTAB do_execsql_test 3.0 { DROP TABLE t1; @@ -86,6 +88,7 @@ do_test fts3corrupt-3.1 { do_catchsql_test 3.2 { SELECT rowid FROM t1 WHERE t1 MATCH 'world' } {1 {database disk image is malformed}} +do_test 3.2.1 { sqlite3_extended_errcode db } SQLITE_CORRUPT_VTAB do_execsql_test 4.0 { @@ -111,6 +114,7 @@ do_catchsql_test 4.2 { UPDATE t1_segdir SET root = X'FFFFFFFFFFFFFFFF'; SELECT rowid FROM t1 WHERE t1 MATCH 'world'; } {1 {database disk image is malformed}} +do_test 4.2.1 { sqlite3_extended_errcode db } SQLITE_CORRUPT_VTAB set blob [binary format cca*cca*cca*cca*cca*cca*cca*cca*cca*cca*a* \ 22 120 [string repeat a 120] \ @@ -130,6 +134,7 @@ do_catchsql_test 4.3 { UPDATE t1_segdir SET root = $blob; SELECT rowid FROM t1 WHERE t1 MATCH 'world'; } {1 {database disk image is malformed}} +do_test 4.3.1 { sqlite3_extended_errcode db } SQLITE_CORRUPT_VTAB # Test a special kind of corruption, where the %_stat table contains # an invalid entry. At one point this could lead to a division-by-zero @@ -152,10 +157,12 @@ do_catchsql_test 5.2 { UPDATE t1_stat SET value = X'0000'; SELECT matchinfo(t1, 'nxa') FROM t1 WHERE t1 MATCH 't*'; } {1 {database disk image is malformed}} +do_test 5.2.1 { sqlite3_extended_errcode db } SQLITE_CORRUPT_VTAB do_catchsql_test 5.3 { UPDATE t1_stat SET value = NULL; SELECT matchinfo(t1, 'nxa') FROM t1 WHERE t1 MATCH 't*'; } {1 {database disk image is malformed}} +do_test 5.3.1 { sqlite3_extended_errcode db } SQLITE_CORRUPT_VTAB finish_test From cc487d13fce19666c4977578864dad9264ea1821 Mon Sep 17 00:00:00 2001 From: drh Date: Tue, 17 May 2011 18:53:08 +0000 Subject: [PATCH 33/40] Add the sqlite3_uri_parameter() interface function for use in building new VFSes. FossilOrigin-Name: 6b5de95fb575c7ceb3034068c4f5e0fccb1b15ac --- manifest | 16 ++++++++-------- manifest.uuid | 2 +- src/main.c | 22 ++++++++++++++++++++++ src/sqlite.h.in | 20 ++++++++++++++++++++ 4 files changed, 51 insertions(+), 9 deletions(-) diff --git a/manifest b/manifest index ab1aadca4c..2c19667b1c 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Add\sextended\sreturn\scode\sSQLITE_CORRUPT_VTAB.\sReturned\swhen\sthe\stcontents\sof\sthe\ssqlite\stables\sused\sinternally\sby\sa\svirtual\stable\smodule\sare\sinvalid\sor\sinconsistent. -D 2011-05-17T15:56:16.473 +C Add\sthe\ssqlite3_uri_parameter()\sinterface\sfunction\sfor\suse\sin\sbuilding\nnew\sVFSes. +D 2011-05-17T18:53:08.942 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 11dcc00a8d0e5202def00e81732784fb0cc4fe1d F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -144,7 +144,7 @@ F src/journal.c 552839e54d1bf76fb8f7abe51868b66acacf6a0e F src/legacy.c a199d7683d60cef73089e892409113e69c23a99f F src/lempar.c 7f026423f4d71d989e719a743f98a1cbd4e6d99e F src/loadext.c 3ae0d52da013a6326310655be6473fd472347b85 -F src/main.c e32d7a44c3307a4a33cfd1a2b06fb46f418ba7fc +F src/main.c d189df8eb4833ca36e93ccf7ba1b5bad6273bfea F src/malloc.c 591aedb20ae40813f1045f2ef253438a334775d9 F src/mem0.c 6a55ebe57c46ca1a7d98da93aaa07f99f1059645 F src/mem1.c 00bd8265c81abb665c48fea1e0c234eb3b922206 @@ -179,7 +179,7 @@ F src/resolve.c 1c0f32b64f8e3f555fe1f732f9d6f501a7f05706 F src/rowset.c 69afa95a97c524ba6faf3805e717b5b7ae85a697 F src/select.c d9d440809025a58547e39f4f268c2a296bfb56ff F src/shell.c 72e7e176bf46d5c6518d15ac4ad6847c4bb5df79 -F src/sqlite.h.in ee13c23409219c0a5fd3f0c0cd761a5073564a0b +F src/sqlite.h.in 8bbf8d9bc5f1a9474a633a2de7014506f1f06b90 F src/sqlite3ext.h c90bd5507099f62043832d73f6425d8d5c5da754 F src/sqliteInt.h b34bd64a7ade4808fcc301e0bb67ef5051ea49c6 F src/sqliteLimit.h 164b0e6749d31e0daa1a4589a169d31c0dec7b3d @@ -936,7 +936,7 @@ F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224 F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e F tool/split-sqlite3c.tcl d9be87f1c340285a3e081eb19b4a247981ed290c F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f -P f7c525f5fc31e909721df2b1e66fc62dfb105718 -R 8174cc733f5a883825d78ae2804a3f2d -U dan -Z 5f2d01dc50656b115009ed665e1773e1 +P 8844e8bfb87314fb40ecb92705e8fff88f72bb38 +R 95d48a407a23b64e1866e265afe49282 +U drh +Z 6f0e27514e0a4b3281aede2f373acd02 diff --git a/manifest.uuid b/manifest.uuid index a4856a4e02..7b2519a73f 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -8844e8bfb87314fb40ecb92705e8fff88f72bb38 \ No newline at end of file +6b5de95fb575c7ceb3034068c4f5e0fccb1b15ac \ No newline at end of file diff --git a/src/main.c b/src/main.c index d19f5f9012..6dd591ce05 100644 --- a/src/main.c +++ b/src/main.c @@ -2908,3 +2908,25 @@ int sqlite3_test_control(int op, ...){ #endif /* SQLITE_OMIT_BUILTIN_TEST */ return rc; } + +/* +** This is a utility routine, useful to VFS implementations, that checks +** to see if a database file was a URI that contained a specific query +** parameter, and if so obtains the value of the query parameter. +** +** The zFilename argument is the filename pointer passed into the xOpen() +** method of a VFS implementation. The zParam argument is the name of the +** query parameter we seek. This routine returns the value of the zParam +** parameter if it exists. If the parameter does not exist, this routine +** returns a NULL pointer. +*/ +const char *sqlite3_uri_parameter(const char *zFilename, const char *zParam){ + zFilename += sqlite3Strlen30(zFilename); + while( zFilename[0] ){ + int x = strcmp(zFilename, zParam); + zFilename += sqlite3Strlen30(zFilename); + if( x==0 ) return zFilename; + zFilename += sqlite3Strlen30(zFilename); + } + return 0; +} diff --git a/src/sqlite.h.in b/src/sqlite.h.in index 4bcba18a95..f955d63741 100644 --- a/src/sqlite.h.in +++ b/src/sqlite.h.in @@ -2553,6 +2553,26 @@ int sqlite3_open_v2( const char *zVfs /* Name of VFS module to use */ ); +/* +** CAPI3REF: Obtain Values For URI Parameters +** +** This is a utility routine, useful to VFS implementations, that checks +** to see if a database file was a URI that contained a specific query +** parameter, and if so obtains the value of the query parameter. +** +** The zFilename argument is the filename pointer passed into the xOpen() +** method of a VFS implementation. The zParam argument is the name of the +** query parameter we seek. This routine returns the value of the zParam +** parameter if it exists. If the parameter does not exist, this routine +** returns a NULL pointer. +** +** If the zFilename argument to this function is not a pointer that SQLite +** passed into the xOpen VFS method, then the behavior of this routine +** is undefined and probably undesirable. +*/ +const char *sqlite3_uri_parameter(const char *zFilename, const char *zParam); + + /* ** CAPI3REF: Error Codes And Messages ** From bd69559bfdfc72d4c1e5741a3bdcd51268cfedd5 Mon Sep 17 00:00:00 2001 From: drh Date: Tue, 17 May 2011 19:43:38 +0000 Subject: [PATCH 34/40] Fix an off-by-one error in the new sqlite3_uri_parameter() function. FossilOrigin-Name: 9593a640795458ce6e57e02dd5d702b642858f76 --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/main.c | 6 +++--- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/manifest b/manifest index 2c19667b1c..1a8a57d2af 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Add\sthe\ssqlite3_uri_parameter()\sinterface\sfunction\sfor\suse\sin\sbuilding\nnew\sVFSes. -D 2011-05-17T18:53:08.942 +C Fix\san\soff-by-one\serror\sin\sthe\snew\ssqlite3_uri_parameter()\sfunction. +D 2011-05-17T19:43:38.641 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 11dcc00a8d0e5202def00e81732784fb0cc4fe1d F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -144,7 +144,7 @@ F src/journal.c 552839e54d1bf76fb8f7abe51868b66acacf6a0e F src/legacy.c a199d7683d60cef73089e892409113e69c23a99f F src/lempar.c 7f026423f4d71d989e719a743f98a1cbd4e6d99e F src/loadext.c 3ae0d52da013a6326310655be6473fd472347b85 -F src/main.c d189df8eb4833ca36e93ccf7ba1b5bad6273bfea +F src/main.c 059daeed5876b3604f0192f838faf5f4db138901 F src/malloc.c 591aedb20ae40813f1045f2ef253438a334775d9 F src/mem0.c 6a55ebe57c46ca1a7d98da93aaa07f99f1059645 F src/mem1.c 00bd8265c81abb665c48fea1e0c234eb3b922206 @@ -936,7 +936,7 @@ F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224 F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e F tool/split-sqlite3c.tcl d9be87f1c340285a3e081eb19b4a247981ed290c F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f -P 8844e8bfb87314fb40ecb92705e8fff88f72bb38 -R 95d48a407a23b64e1866e265afe49282 +P 6b5de95fb575c7ceb3034068c4f5e0fccb1b15ac +R d104cfa9424db95a1c8ed2af31b70a54 U drh -Z 6f0e27514e0a4b3281aede2f373acd02 +Z e3568578d123c11b9aea2de4d2897b24 diff --git a/manifest.uuid b/manifest.uuid index 7b2519a73f..0fe7c3a736 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -6b5de95fb575c7ceb3034068c4f5e0fccb1b15ac \ No newline at end of file +9593a640795458ce6e57e02dd5d702b642858f76 \ No newline at end of file diff --git a/src/main.c b/src/main.c index 6dd591ce05..c99d396546 100644 --- a/src/main.c +++ b/src/main.c @@ -2921,12 +2921,12 @@ int sqlite3_test_control(int op, ...){ ** returns a NULL pointer. */ const char *sqlite3_uri_parameter(const char *zFilename, const char *zParam){ - zFilename += sqlite3Strlen30(zFilename); + zFilename += sqlite3Strlen30(zFilename) + 1; while( zFilename[0] ){ int x = strcmp(zFilename, zParam); - zFilename += sqlite3Strlen30(zFilename); + zFilename += sqlite3Strlen30(zFilename) + 1; if( x==0 ) return zFilename; - zFilename += sqlite3Strlen30(zFilename); + zFilename += sqlite3Strlen30(zFilename) + 1; } return 0; } From 81cc516352d809335f78de86b785b3f532ae5254 Mon Sep 17 00:00:00 2001 From: drh Date: Tue, 17 May 2011 20:36:21 +0000 Subject: [PATCH 35/40] Add the ability to limit filenames to 8+3 using the SQLITE_ENABLE_8_3_NAMES compile-time option together with a URI parameter of "8_3_names=1". FossilOrigin-Name: 96d609856025919571f781207dfa6a24b1732e8d --- manifest | 27 +++--- manifest.uuid | 2 +- src/os_unix.c | 19 +++-- src/os_win.c | 1 + src/pager.c | 2 + src/pragma.c | 10 +-- src/sqliteInt.h | 6 ++ src/test_config.c | 6 ++ src/util.c | 26 ++++++ src/vdbeaux.c | 1 + test/8_3_names.test | 197 ++++++++++++++++++++++++++++++++++++++++++++ 11 files changed, 271 insertions(+), 26 deletions(-) create mode 100644 test/8_3_names.test diff --git a/manifest b/manifest index 1a8a57d2af..3d4df4239f 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\san\soff-by-one\serror\sin\sthe\snew\ssqlite3_uri_parameter()\sfunction. -D 2011-05-17T19:43:38.641 +C Add\sthe\sability\sto\slimit\sfilenames\sto\s8+3\susing\sthe\nSQLITE_ENABLE_8_3_NAMES\scompile-time\soption\stogether\swith\sa\sURI\nparameter\sof\s"8_3_names=1". +D 2011-05-17T20:36:21.474 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 11dcc00a8d0e5202def00e81732784fb0cc4fe1d F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -163,15 +163,15 @@ F src/os.c 22ac61d06e72a0dac900400147333b07b13d8e1d F src/os.h 9dbed8c2b9c1f2f2ebabc09e49829d4777c26bf9 F src/os_common.h a8f95b81eca8a1ab8593d23e94f8a35f35d4078f F src/os_os2.c 4a75888ba3dfc820ad5e8177025972d74d7f2440 -F src/os_unix.c 2c67d126874b78eb427371db4793f0e8fbc7448b -F src/os_win.c ff0e14615a5086fa5ba6926e4ec0dc9cfb5a1a84 -F src/pager.c ebf0411b037fbc6dec272520be55fc11423e789a +F src/os_unix.c 6d4a58d81ad4b782406519f3790202f330e89bb7 +F src/os_win.c 218b899469e570d46eb8147c2383075f7c026230 +F src/pager.c b7fe4b8e51d51a062618c4630c40d20a1a44cb80 F src/pager.h 3f8c783de1d4706b40b1ac15b64f5f896bcc78d1 F src/parse.y 12b7ebd61ea54f0e1b1083ff69cc2c8ce9353d58 F src/pcache.c 09d38c44ab275db581f7a2f6ff8b9bc7f8c0faaa F src/pcache.h c683390d50f856d4cd8e24342ae62027d1bb6050 F src/pcache1.c d548e31beafa792d1994b663a29a5303569efc4e -F src/pragma.c 49c90ab27a4339d4b5bc0b03c08cbcf20ed8d454 +F src/pragma.c 9e778decc3ee9bcaf88904b4a3b0a4360aaf0eab F src/prepare.c e64261559a3187698a3e7e6c8b001a4f4f98dab4 F src/printf.c 585a36b6a963df832cfb69505afa3a34ed5ef8a1 F src/random.c cd4a67b3953b88019f8cd4ccd81394a8ddfaba50 @@ -181,7 +181,7 @@ F src/select.c d9d440809025a58547e39f4f268c2a296bfb56ff F src/shell.c 72e7e176bf46d5c6518d15ac4ad6847c4bb5df79 F src/sqlite.h.in 8bbf8d9bc5f1a9474a633a2de7014506f1f06b90 F src/sqlite3ext.h c90bd5507099f62043832d73f6425d8d5c5da754 -F src/sqliteInt.h b34bd64a7ade4808fcc301e0bb67ef5051ea49c6 +F src/sqliteInt.h 771087591052966d36ac1fcd3c8bb7a8c6cf9a38 F src/sqliteLimit.h 164b0e6749d31e0daa1a4589a169d31c0dec7b3d F src/status.c 7ac64842c86cec2fc1a1d0e5c16d3beb8ad332bf F src/table.c 2cd62736f845d82200acfa1287e33feb3c15d62e @@ -199,7 +199,7 @@ F src/test_async.c 0612a752896fad42d55c3999a5122af10dcf22ad F src/test_autoext.c 30e7bd98ab6d70a62bb9ba572e4c7df347fe645e F src/test_backup.c c129c91127e9b46e335715ae2e75756e25ba27de F src/test_btree.c 47cd771250f09cdc6e12dda5bc71bc0b3abc96e2 -F src/test_config.c d536042f27226b4639f0f87d4795fd37428a9ddf +F src/test_config.c 9a6aa8301a56906612b5e70f5b38e80cfb8af8e7 F src/test_demovfs.c 938d0f595f8bd310076e1c06cf7885a01ce7ce01 F src/test_devsym.c e7498904e72ba7491d142d5c83b476c4e76993bc F src/test_func.c cbdec5cededa0761daedde5baf06004a9bf416b5 @@ -234,13 +234,13 @@ F src/tokenize.c 604607d6813e9551cf5189d899e0a25c12681080 F src/trigger.c 144cc18bb701f3286484aae4292a9531f09278c8 F src/update.c 5bcb56e5c7380a2eecb0e71891dbd4ad7437748f F src/utf.c d83650c3ea08f7407bd9d0839d9885241c209c60 -F src/util.c 914e860d21496b19a912cd14f6f7a889a22f44e1 +F src/util.c 5f4ba293a4bce63aab6885edde6261b007b34a20 F src/vacuum.c 05513dca036a1e7848fe18d5ed1265ac0b32365e F src/vdbe.c 343a068e8daeb8475e66776feb9f2974046e95c5 F src/vdbe.h 8a675fefdf7119441fe817c800a9a52440c2e797 F src/vdbeInt.h fe8f58d305e629fff02f61f655aca1d299f1f6ae F src/vdbeapi.c e0e2672e0a96ae3f8575c8ecd02912a3e8a554a1 -F src/vdbeaux.c 25aa5ba7d46b4fe7c8f33dc132d474242d5f9726 +F src/vdbeaux.c 535851211df61d83213c83d5ffd3c6ce9ecbdc18 F src/vdbeblob.c c3ccb7c8732858c680f442932e66ad06bb036562 F src/vdbemem.c 0498796b6ffbe45e32960d6a1f5adfb6e419883b F src/vdbetrace.c 5d0dc3d5fd54878cc8d6d28eb41deb8d5885b114 @@ -249,6 +249,7 @@ F src/wal.c de27c34c8016c00be348fc6bed588816557ceb66 F src/wal.h 66b40bd91bc29a5be1c88ddd1f5ade8f3f48728a F src/walker.c 3112bb3afe1d85dc52317cb1d752055e9a781f8f F src/where.c 55403ce19c506be6a321c7f129aff693d6103db5 +F test/8_3_names.test b93687beebd17f6ebf812405a6833bae5d1f4199 F test/aggerror.test a867e273ef9e3d7919f03ef4f0e8c0d2767944f2 F test/alias.test 4529fbc152f190268a15f9384a5651bbbabc9d87 F test/all.test 51756962d522e474338e9b2ebb26e7364d4aa125 @@ -936,7 +937,7 @@ F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224 F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e F tool/split-sqlite3c.tcl d9be87f1c340285a3e081eb19b4a247981ed290c F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f -P 6b5de95fb575c7ceb3034068c4f5e0fccb1b15ac -R d104cfa9424db95a1c8ed2af31b70a54 +P 9593a640795458ce6e57e02dd5d702b642858f76 +R 87dd50ad185017288f71d71ad9ceabb5 U drh -Z e3568578d123c11b9aea2de4d2897b24 +Z 1ba151bdfae18403ba429fed62365eed diff --git a/manifest.uuid b/manifest.uuid index 0fe7c3a736..c295187117 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -9593a640795458ce6e57e02dd5d702b642858f76 \ No newline at end of file +96d609856025919571f781207dfa6a24b1732e8d \ No newline at end of file diff --git a/src/os_unix.c b/src/os_unix.c index a760e2c147..c768dcfa76 100644 --- a/src/os_unix.c +++ b/src/os_unix.c @@ -3769,6 +3769,7 @@ static int unixOpenSharedMemory(unixFile *pDbFd){ (u32)sStat.st_ino, (u32)sStat.st_dev); #else sqlite3_snprintf(nShmFilename, zShmFilename, "%s-shm", pDbFd->zPath); + sqlite3FileSuffix3(pDbFd->zPath, zShmFilename); #endif pShmNode->h = -1; pDbFd->pInode->pShmNode = pShmNode; @@ -4802,6 +4803,11 @@ static UnixUnusedFd *findReusableFd(const char *zPath, int flags){ ** corresponding database file and sets *pMode to this value. Whenever ** possible, WAL and journal files are created using the same permissions ** as the associated database file. +** +** If the SQLITE_ENABLE_8_3_NAMES option is enabled, then the +** original filename is unavailable. But 8_3_NAMES is only used for +** FAT filesystems and permissions do not matter there, so just use +** the default permissions. */ static int findCreateFileMode( const char *zPath, /* Path of file (possibly) being created */ @@ -4809,6 +4815,7 @@ static int findCreateFileMode( mode_t *pMode /* OUT: Permissions to open file with */ ){ int rc = SQLITE_OK; /* Return Code */ + *pMode = SQLITE_DEFAULT_FILE_PERMISSIONS; if( flags & (SQLITE_OPEN_WAL|SQLITE_OPEN_MAIN_JOURNAL) ){ char zDb[MAX_PATHNAME+1]; /* Database file path */ int nDb; /* Number of valid bytes in zDb */ @@ -4820,15 +4827,15 @@ static int findCreateFileMode( ** ** "-journal" ** "-wal" - ** "-journal-NNNN" - ** "-wal-NNNN" + ** "-journalNN" + ** "-walNN" ** - ** where NNNN is a 4 digit decimal number. The NNNN naming schemes are + ** where NN is a 4 digit decimal number. The NN naming schemes are ** used by the test_multiplex.c module. */ nDb = sqlite3Strlen30(zPath) - 1; - while( nDb>0 && zPath[nDb]!='l' ) nDb--; - nDb -= ((flags & SQLITE_OPEN_WAL) ? 3 : 7); + while( nDb>0 && zPath[nDb]!='-' ) nDb--; + if( nDb==0 ) return SQLITE_OK; memcpy(zDb, zPath, nDb); zDb[nDb] = '\0'; @@ -4839,8 +4846,6 @@ static int findCreateFileMode( } }else if( flags & SQLITE_OPEN_DELETEONCLOSE ){ *pMode = 0600; - }else{ - *pMode = SQLITE_DEFAULT_FILE_PERMISSIONS; } return rc; } diff --git a/src/os_win.c b/src/os_win.c index 1300b90143..b3e47f8363 100644 --- a/src/os_win.c +++ b/src/os_win.c @@ -1570,6 +1570,7 @@ static int winOpenSharedMemory(winFile *pDbFd){ memset(pNew, 0, sizeof(*pNew)); pNew->zFilename = (char*)&pNew[1]; sqlite3_snprintf(nName+15, pNew->zFilename, "%s-shm", pDbFd->zPath); + sqlite3FileSuffix3(pDbFd->zPath, pNew->zFilename); /* Look to see if there is an existing winShmNode that can be used. ** If no matching winShmNode currently exists, create a new one. diff --git a/src/pager.c b/src/pager.c index 24db850273..b622c7acfe 100644 --- a/src/pager.c +++ b/src/pager.c @@ -4405,10 +4405,12 @@ int sqlite3PagerOpen( memcpy(&pPager->zFilename[nPathname+1], zUri, nUri); memcpy(pPager->zJournal, zPathname, nPathname); memcpy(&pPager->zJournal[nPathname], "-journal", 8); + sqlite3FileSuffix3(pPager->zFilename, pPager->zJournal); #ifndef SQLITE_OMIT_WAL pPager->zWal = &pPager->zJournal[nPathname+8+1]; memcpy(pPager->zWal, zPathname, nPathname); memcpy(&pPager->zWal[nPathname], "-wal", 4); + sqlite3FileSuffix3(pPager->zFilename, pPager->zWal); #endif sqlite3_free(zPathname); } diff --git a/src/pragma.c b/src/pragma.c index 75ab26d441..799805c40b 100644 --- a/src/pragma.c +++ b/src/pragma.c @@ -49,7 +49,7 @@ static u8 getSafetyLevel(const char *z){ /* ** Interpret the given string as a boolean value. */ -static u8 getBoolean(const char *z){ +u8 sqlite3GetBoolean(const char *z){ return getSafetyLevel(z)&1; } @@ -219,7 +219,7 @@ static int flagPragma(Parse *pParse, const char *zLeft, const char *zRight){ mask &= ~(SQLITE_ForeignKeys); } - if( getBoolean(zRight) ){ + if( sqlite3GetBoolean(zRight) ){ db->flags |= mask; }else{ db->flags &= ~mask; @@ -433,7 +433,7 @@ void sqlite3Pragma( int b = -1; assert( pBt!=0 ); if( zRight ){ - b = getBoolean(zRight); + b = sqlite3GetBoolean(zRight); } if( pId2->n==0 && b>=0 ){ int ii; @@ -1033,7 +1033,7 @@ void sqlite3Pragma( #ifndef NDEBUG if( sqlite3StrICmp(zLeft, "parser_trace")==0 ){ if( zRight ){ - if( getBoolean(zRight) ){ + if( sqlite3GetBoolean(zRight) ){ sqlite3ParserTrace(stderr, "parser: "); }else{ sqlite3ParserTrace(0, 0); @@ -1047,7 +1047,7 @@ void sqlite3Pragma( */ if( sqlite3StrICmp(zLeft, "case_sensitive_like")==0 ){ if( zRight ){ - sqlite3RegisterLikeFunctions(db, getBoolean(zRight)); + sqlite3RegisterLikeFunctions(db, sqlite3GetBoolean(zRight)); } }else diff --git a/src/sqliteInt.h b/src/sqliteInt.h index 4a3e45d7c0..6932e0b455 100644 --- a/src/sqliteInt.h +++ b/src/sqliteInt.h @@ -2941,6 +2941,12 @@ int sqlite3AddInt64(i64*,i64); int sqlite3SubInt64(i64*,i64); int sqlite3MulInt64(i64*,i64); int sqlite3AbsInt32(int); +#ifdef SQLITE_ENABLE_8_3_NAMES +void sqlite3FileSuffix3(const char*, char*); +#else +# define sqlite3FileSuffix3(X,Y) +#endif +u8 sqlite3GetBoolean(const char *z); const void *sqlite3ValueText(sqlite3_value*, u8); int sqlite3ValueBytes(sqlite3_value*, u8); diff --git a/src/test_config.c b/src/test_config.c index 03d2f4e976..92f343f458 100644 --- a/src/test_config.c +++ b/src/test_config.c @@ -73,6 +73,12 @@ static void set_options(Tcl_Interp *interp){ Tcl_SetVar2(interp, "sqlite_options", "memdebug", "0", TCL_GLOBAL_ONLY); #endif +#ifdef SQLITE_ENABLE_8_3_NAMES + Tcl_SetVar2(interp, "sqlite_options", "8_3_names", "1", TCL_GLOBAL_ONLY); +#else + Tcl_SetVar2(interp, "sqlite_options", "8_3_names", "0", TCL_GLOBAL_ONLY); +#endif + #ifdef SQLITE_ENABLE_MEMSYS3 Tcl_SetVar2(interp, "sqlite_options", "mem3", "1", TCL_GLOBAL_ONLY); #else diff --git a/src/util.c b/src/util.c index 50dc591207..7e271aac05 100644 --- a/src/util.c +++ b/src/util.c @@ -1146,3 +1146,29 @@ int sqlite3AbsInt32(int x){ if( x==(int)0x80000000 ) return 0x7fffffff; return -x; } + +#ifdef SQLITE_ENABLE_8_3_NAMES +/* +** If SQLITE_ENABLE_8_3_NAME is set at compile-time and if the database +** filename in zBaseFilename is a URI with the "8_3_names=1" parameter and +** if filename in z[] has a suffix (a.k.a. "extension") that is longer than +** three characters, then shorten the suffix on z[] to be the last three +** characters of the original suffix. +** +** Examples: +** +** test.db-journal => test.nal +** test.db-wal => test.wal +** test.db-shm => test.shm +*/ +void sqlite3FileSuffix3(const char *zBaseFilename, char *z){ + const char *zOk; + zOk = sqlite3_uri_parameter(zBaseFilename, "8_3_names"); + if( zOk && sqlite3GetBoolean(zOk) ){ + int i, sz; + sz = sqlite3Strlen30(z); + for(i=sz-1; i>0 && z[i]!='/' && z[i]!='\\' && z[i]!='.'; i--){} + if( z[i]=='.' && sz>i+4 ) memcpy(&z[i+1], &z[sz-3], 4); + } +} +#endif diff --git a/src/vdbeaux.c b/src/vdbeaux.c index 0c7b11f1e1..e89a87b522 100644 --- a/src/vdbeaux.c +++ b/src/vdbeaux.c @@ -1799,6 +1799,7 @@ static int vdbeCommit(sqlite3 *db, Vdbe *p){ if( !zMaster ){ return SQLITE_NOMEM; } + sqlite3FileSuffix3(zMainFile, zMaster); rc = sqlite3OsAccess(pVfs, zMaster, SQLITE_ACCESS_EXISTS, &res); }while( rc==SQLITE_OK && res ); if( rc==SQLITE_OK ){ diff --git a/test/8_3_names.test b/test/8_3_names.test new file mode 100644 index 0000000000..418685e64b --- /dev/null +++ b/test/8_3_names.test @@ -0,0 +1,197 @@ +# 2011 May 17 +# +# 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. +# +#*********************************************************************** +# +# Test cases for the SQLITE_ENABLE_8_3_NAMES feature that forces all +# filename extensions to be limited to 3 characters. Some embedded +# systems need this to work around microsoft FAT patents, but this +# feature should be disabled on most deployments. +# + +set testdir [file dirname $argv0] +source $testdir/tester.tcl +ifcapable !8_3_names { + finish_test + return +} + +db close +sqlite3_shutdown +sqlite3_config_uri 1 + +do_test 8_3_names-1.0 { + forcedelete test.db test.nal test.db-journal + sqlite3 db test.db + db eval { + PRAGMA cache_size=10; + CREATE TABLE t1(x); + INSERT INTO t1 VALUES(randomblob(20000)); + BEGIN; + DELETE FROM t1; + INSERT INTO t1 VALUES(randomblob(15000)); + } + file exists test.db-journal +} 1 +do_test 8_3_names-1.1 { + file exists test.nal +} 0 +do_test 8_3_names-1.2 { + db eval { + ROLLBACK; + SELECT length(x) FROM t1 + } +} 20000 + +db close +do_test 8_3_names-2.0 { + forcedelete test.db test.nal test.db-journal + sqlite3 db file:./test.db?8_3_names=1 + db eval { + PRAGMA cache_size=10; + CREATE TABLE t1(x); + INSERT INTO t1 VALUES(randomblob(20000)); + BEGIN; + DELETE FROM t1; + INSERT INTO t1 VALUES(randomblob(15000)); + } + file exists test.db-journal +} 0 +do_test 8_3_names-2.1 { + file exists test.nal +} 1 +forcedelete test2.db test2.nal test2.db-journal +file copy test.db test2.db +file copy test.nal test2.nal +do_test 8_3_names-2.2 { + db eval { + COMMIT; + SELECT length(x) FROM t1 + } +} 15000 +do_test 8_3_names-2.3 { + sqlite3 db2 file:./test2.db?8_3_names=1 + db2 eval { + PRAGMA integrity_check; + SELECT length(x) FROM t1; + } +} {ok 20000} + +db close +do_test 8_3_names-3.0 { + forcedelete test.db test.nal test.db-journal + sqlite3 db file:./test.db?8_3_names=0 + db eval { + PRAGMA cache_size=10; + CREATE TABLE t1(x); + INSERT INTO t1 VALUES(randomblob(20000)); + BEGIN; + DELETE FROM t1; + INSERT INTO t1 VALUES(randomblob(15000)); + } + file exists test.db-journal +} 1 +do_test 8_3_names-3.1 { + file exists test.nal +} 0 +forcedelete test2.db test2.nal test2.db-journal +file copy test.db test2.db +file copy test.db-journal test2.db-journal +do_test 8_3_names-3.2 { + db eval { + COMMIT; + SELECT length(x) FROM t1 + } +} 15000 +do_test 8_3_names-3.3 { + sqlite3 db2 file:./test2.db?8_3_names=0 + db2 eval { + PRAGMA integrity_check; + SELECT length(x) FROM t1; + } +} {ok 20000} + +########################################################################## +# Master journals. +# +db close +forcedelete test.db test2.db +do_test 8_3_names-4.0 { + sqlite3 db file:./test.db?8_3_names=1 + db eval { + CREATE TABLE t1(x); + INSERT INTO t1 VALUES(1); + ATTACH 'file:./test2.db?8_3_names=1' AS db2; + CREATE TABLE db2.t2(y); + INSERT INTO t2 VALUES(2); + BEGIN; + INSERT INTO t1 VALUES(3); + INSERT INTO t2 VALUES(4); + COMMIT; + SELECT * FROM t1, t2 ORDER BY x, y + } +} {1 2 1 4 3 2 3 4} + + +########################################################################## +# WAL mode. +# +ifcapable !wal { + finish_test + return +} +db close +forcedelete test.db +do_test 8_3_names-5.0 { + sqlite3 db file:./test.db?8_3_names=1 + register_wholenumber_module db + db eval { + PRAGMA journal_mode=WAL; + CREATE TABLE t1(x); + CREATE VIRTUAL TABLE nums USING wholenumber; + INSERT INTO t1 SELECT value FROM nums WHERE value BETWEEN 1 AND 1000; + BEGIN; + UPDATE t1 SET x=x*2; + } + sqlite3 db2 file:./test.db?8_3_names=1 + register_wholenumber_module db2 + db2 eval { + BEGIN; + SELECT sum(x) FROM t1; + } +} {500500} + +do_test 8_3_names-5.1 { + file exists test.db-wal +} 0 +do_test 8_3_names-5.2 { + file exists test.wal +} 1 +do_test 8_3_names-5.3 { + file exists test.db-shm +} 0 +do_test 8_3_names-5.4 { + file exists test.shm +} 1 + + +do_test 8_3_names-5.5 { + db eval { + COMMIT; + SELECT sum(x) FROM t1; + } +} {1001000} +do_test 8_3_names-5.6 { + db2 eval { + SELECT sum(x) FROM t1; + } +} {500500} + + +finish_test From cc4e19be9a2d5076c6d05891859c3bd3f90a4ac8 Mon Sep 17 00:00:00 2001 From: shaneh Date: Wed, 18 May 2011 02:22:41 +0000 Subject: [PATCH 36/40] Update multiplex VFS to handle empty filenames which can occur for during vacuuming (temp file names.) FossilOrigin-Name: a074986045f1a81fb831ffee4a29af13c978b053 --- manifest | 16 +++---- manifest.uuid | 2 +- src/test_multiplex.c | 111 ++++++++++++++++++++++++++++++++++++------- test/multiplex.test | 40 ++++++++++++++++ 4 files changed, 142 insertions(+), 27 deletions(-) diff --git a/manifest b/manifest index 3d4df4239f..9a8c046453 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Add\sthe\sability\sto\slimit\sfilenames\sto\s8+3\susing\sthe\nSQLITE_ENABLE_8_3_NAMES\scompile-time\soption\stogether\swith\sa\sURI\nparameter\sof\s"8_3_names=1". -D 2011-05-17T20:36:21.474 +C Update\smultiplex\sVFS\sto\shandle\sempty\sfilenames\swhich\scan\soccur\sfor\sduring\svacuuming\s(temp\sfile\snames.) +D 2011-05-18T02:22:41.100 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 11dcc00a8d0e5202def00e81732784fb0cc4fe1d F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -211,7 +211,7 @@ F src/test_intarray.h 489edb9068bb926583445cb02589344961054207 F src/test_journal.c 785edd54f963aefb3c1628124170a56697c68c70 F src/test_loadext.c df586c27176e3c2cb2e099c78da67bf14379a56e F src/test_malloc.c 7ca7be34e0e09ef0ed6619544552ed95732e41f6 -F src/test_multiplex.c fdabd793ee7a9642c5a8a470def2347144c46d05 +F src/test_multiplex.c c71f0a0cdf2b89a441e0bcefb2fcdf1dd358a820 F src/test_multiplex.h e99c571bc4968b7a9363b661481f3934bfead61d F src/test_mutex.c a6bd7b9cf6e19d989e31392b06ac8d189f0d573e F src/test_onefile.c 40cf9e212a377a6511469384a64b01e6e34b2eec @@ -590,7 +590,7 @@ F test/misc5.test 45b2e3ed5f79af2b4f38ae362eaf4c49674575bd F test/misc6.test 953cc693924d88e6117aeba16f46f0bf5abede91 F test/misc7.test 29032efcd3d826fbd409e2a7af873e7939f4a4e3 F test/misuse.test 30b3a458e5a70c31e74c291937b6c82204c59f33 -F test/multiplex.test a88f3e2c16e567e72be7296195c59fbdd6a8d3d4 +F test/multiplex.test 7a8a50c8ed72dfcf4db9ebae977f7a63184639d8 F test/mutex1.test 78b2b9bb320e51d156c4efdb71b99b051e7a4b41 F test/mutex2.test bfeaeac2e73095b2ac32285d2756e3a65e681660 F test/nan.test dc212a22b36109fd1ae37154292444ef249c5ec2 @@ -937,7 +937,7 @@ F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224 F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e F tool/split-sqlite3c.tcl d9be87f1c340285a3e081eb19b4a247981ed290c F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f -P 9593a640795458ce6e57e02dd5d702b642858f76 -R 87dd50ad185017288f71d71ad9ceabb5 -U drh -Z 1ba151bdfae18403ba429fed62365eed +P 96d609856025919571f781207dfa6a24b1732e8d +R 2d9bd612a3d2dc8f2665702baad38baa +U shaneh +Z d27048d3dae68da084505a60e1541c3b diff --git a/manifest.uuid b/manifest.uuid index c295187117..1dc5ed78fb 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -96d609856025919571f781207dfa6a24b1732e8d \ No newline at end of file +a074986045f1a81fb831ffee4a29af13c978b053 \ No newline at end of file diff --git a/src/test_multiplex.c b/src/test_multiplex.c index d8a7db86e1..861e68e877 100644 --- a/src/test_multiplex.c +++ b/src/test_multiplex.c @@ -185,13 +185,72 @@ static void multiplexLeave(void){ sqlite3_mutex_leave(gMultiplex.pMutex); } ** than the actual length of the string. For very long strings (greater ** than 1GiB) the value returned might be less than the true string length. */ -int multiplexStrlen30(const char *z){ +static int multiplexStrlen30(const char *z){ const char *z2 = z; if( z==0 ) return 0; while( *z2 ){ z2++; } return 0x3fffffff & (int)(z2 - z); } +/* +** Create a temporary file name in zBuf. zBuf must be big enough to +** hold at pOrigVfs->mxPathname characters. This function departs +** from the traditional temporary name generation in the os_win +** and os_unix VFS in several ways, but is necessary so that +** the file name is known for temporary files (like those used +** during vacuum.) +** +** N.B. This routine assumes your underlying VFS is ok with using +** "/" as a directory seperator. This is the default for UNIXs +** and is allowed (even mixed) for most versions of Windows. +*/ +static int multiplexGetTempname(sqlite3_vfs *pOrigVfs, int nBuf, char *zBuf){ + static char zChars[] = + "abcdefghijklmnopqrstuvwxyz" + "ABCDEFGHIJKLMNOPQRSTUVWXYZ" + "0123456789"; + int i,j; + int attempts = 0; + int exists = 0; + int rc = SQLITE_ERROR; + + /* Check that the output buffer is large enough for + ** pVfs->mxPathname characters. + */ + if( pOrigVfs->mxPathname <= nBuf ){ + + /* sqlite3_temp_directory should always be less than + ** pVfs->mxPathname characters. + */ + sqlite3_snprintf(pOrigVfs->mxPathname, + zBuf, + "%s/", + sqlite3_temp_directory ? sqlite3_temp_directory : "."); + + /* Check that the output buffer is large enough for the temporary file + ** name. + */ + j = multiplexStrlen30(zBuf); + if( (j + 8 + 1 + 3 + 1) <= nBuf ){ + /* Make 3 attempts to generate a unique name. */ + do { + attempts++; + sqlite3_randomness(8, &zBuf[j]); + for(i=0; i<8; i++){ + zBuf[j+i] = (char)zChars[ ((unsigned char)zBuf[j+i])%(sizeof(zChars)-1) ]; + } + memcpy(&zBuf[j+i], ".tmp", 5); + rc = pOrigVfs->xAccess(pOrigVfs, zBuf, SQLITE_ACCESS_EXISTS, &exists); + } while ( (rc==SQLITE_OK) && exists && (attempts<3) ); + if( rc==SQLITE_OK && exists ){ + rc = SQLITE_ERROR; + } + } + } + + return rc; +} + /* Translate an sqlite3_file* that is really a multiplexGroup* into ** the sqlite3_file* for the underlying original VFS. */ @@ -295,12 +354,12 @@ static int multiplexOpen( int flags, /* Flags to control the opening */ int *pOutFlags /* Flags showing results of opening */ ){ - int rc; /* Result code */ + int rc = SQLITE_OK; /* Result code */ multiplexConn *pMultiplexOpen; /* The new multiplex file descriptor */ multiplexGroup *pGroup; /* Corresponding multiplexGroup object */ sqlite3_file *pSubOpen; /* Real file descriptor */ sqlite3_vfs *pOrigVfs = gMultiplex.pOrigVfs; /* Real VFS */ - int nName = multiplexStrlen30(zName); + int nName; int i; int sz; @@ -311,23 +370,39 @@ static int multiplexOpen( */ multiplexEnter(); pMultiplexOpen = (multiplexConn*)pConn; - /* allocate space for group */ - sz = sizeof(multiplexGroup) /* multiplexGroup */ - + (sizeof(sqlite3_file *)*SQLITE_MULTIPLEX_MAX_CHUNKS) /* pReal[] */ - + (pOrigVfs->szOsFile*SQLITE_MULTIPLEX_MAX_CHUNKS) /* *pReal */ - + SQLITE_MULTIPLEX_MAX_CHUNKS /* bOpen[] */ - + nName + 1; /* zName */ + + /* If the second argument to this function is NULL, generate a + ** temporary file name to use. This will be handled by the + ** original xOpen method. We just need to allocate space for + ** it. + */ + if( !zName ){ + rc = multiplexGetTempname(pOrigVfs, pOrigVfs->mxPathname, gMultiplex.zName); + zName = gMultiplex.zName; + } + + if( rc==SQLITE_OK ){ + /* allocate space for group */ + nName = multiplexStrlen30(zName); + sz = sizeof(multiplexGroup) /* multiplexGroup */ + + (sizeof(sqlite3_file *)*SQLITE_MULTIPLEX_MAX_CHUNKS) /* pReal[] */ + + (pOrigVfs->szOsFile*SQLITE_MULTIPLEX_MAX_CHUNKS) /* *pReal */ + + SQLITE_MULTIPLEX_MAX_CHUNKS /* bOpen[] */ + + nName + 1; /* zName */ #ifndef SQLITE_MULTIPLEX_EXT_OVWR - sz += SQLITE_MULTIPLEX_EXT_SZ; - assert(nName+SQLITE_MULTIPLEX_EXT_SZ < pOrigVfs->mxPathname); + sz += SQLITE_MULTIPLEX_EXT_SZ; + assert(nName+SQLITE_MULTIPLEX_EXT_SZ < pOrigVfs->mxPathname); #else - assert(nName >= SQLITE_MULTIPLEX_EXT_SZ); - assert(nName < pOrigVfs->mxPathname); + assert(nName >= SQLITE_MULTIPLEX_EXT_SZ); + assert(nName < pOrigVfs->mxPathname); #endif - pGroup = sqlite3_malloc( sz ); - if( pGroup==0 ){ - rc=SQLITE_NOMEM; - }else{ + pGroup = sqlite3_malloc( sz ); + if( pGroup==0 ){ + rc=SQLITE_NOMEM; + } + } + + if( rc==SQLITE_OK ){ /* assign pointers to extra space allocated */ char *p = (char *)&pGroup[1]; pMultiplexOpen->pGroup = pGroup; @@ -411,7 +486,7 @@ static int multiplexDelete( } rc2 = pOrigVfs->xAccess(pOrigVfs, gMultiplex.zName, SQLITE_ACCESS_EXISTS, &exists); - if( rc2==SQLITE_OK && exists){ + if( rc2==SQLITE_OK && exists ){ /* if it exists, delete it */ rc2 = pOrigVfs->xDelete(pOrigVfs, gMultiplex.zName, syncDir); if( rc2!=SQLITE_OK ) rc = rc2; diff --git a/test/multiplex.test b/test/multiplex.test index 518cbe37a0..ae60d639e5 100644 --- a/test/multiplex.test +++ b/test/multiplex.test @@ -567,5 +567,45 @@ if {0==[info exists ::G(perm:presql)] || $::G(perm:presql) == ""} { } } +#------------------------------------------------------------------------- +# Test that you can vacuum a multiplex'ed DB. + +ifcapable vacuum { + +do_test multiplex-6.0.0 { + multiplex_delete test.db + sqlite3_multiplex_initialize "" 1 + sqlite3 db test.db + multiplex_set db main 4096 16 +} {SQLITE_OK} + +do_test multiplex-6.1.0 { + execsql { + PRAGMA page_size=1024; + PRAGMA journal_mode=DELETE; + PRAGMA auto_vacuum=OFF; + } + execsql { + CREATE TABLE t1(a, b); + INSERT INTO t1 VALUES(1, randomblob($g_chunk_size)); + INSERT INTO t1 VALUES(2, randomblob($g_chunk_size)); + } +} {} +do_test multiplex-6.2.1 { file size [multiplex_name test.db 0] } [list $g_chunk_size] +do_test multiplex-6.2.2 { file size [multiplex_name test.db 1] } [list $g_chunk_size] + +do_test multiplex-6.3.0 { + execsql { VACUUM } +} {} + +do_test multiplex-6.99 { + db close + multiplex_delete test.db + sqlite3_multiplex_shutdown +} {SQLITE_OK} + +} + + catch { sqlite3_multiplex_shutdown } finish_test From c83f2d477c16d820a9a13a3824923a7085304eef Mon Sep 17 00:00:00 2001 From: drh Date: Wed, 18 May 2011 02:41:10 +0000 Subject: [PATCH 37/40] Remove unreachable branches from the 8.3 filename logic. FossilOrigin-Name: 4f7e7b44f2d17681318a1fd22466d3cc03103fc4 --- manifest | 14 +++++++------- manifest.uuid | 2 +- src/util.c | 4 ++-- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/manifest b/manifest index 9a8c046453..c9ce396096 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Update\smultiplex\sVFS\sto\shandle\sempty\sfilenames\swhich\scan\soccur\sfor\sduring\svacuuming\s(temp\sfile\snames.) -D 2011-05-18T02:22:41.100 +C Remove\sunreachable\sbranches\sfrom\sthe\s8.3\sfilename\slogic. +D 2011-05-18T02:41:10.584 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 11dcc00a8d0e5202def00e81732784fb0cc4fe1d F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -234,7 +234,7 @@ F src/tokenize.c 604607d6813e9551cf5189d899e0a25c12681080 F src/trigger.c 144cc18bb701f3286484aae4292a9531f09278c8 F src/update.c 5bcb56e5c7380a2eecb0e71891dbd4ad7437748f F src/utf.c d83650c3ea08f7407bd9d0839d9885241c209c60 -F src/util.c 5f4ba293a4bce63aab6885edde6261b007b34a20 +F src/util.c 0f33bbbdfcc4a2d8cf20c3b2a16ffc3b57c58a70 F src/vacuum.c 05513dca036a1e7848fe18d5ed1265ac0b32365e F src/vdbe.c 343a068e8daeb8475e66776feb9f2974046e95c5 F src/vdbe.h 8a675fefdf7119441fe817c800a9a52440c2e797 @@ -937,7 +937,7 @@ F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224 F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e F tool/split-sqlite3c.tcl d9be87f1c340285a3e081eb19b4a247981ed290c F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f -P 96d609856025919571f781207dfa6a24b1732e8d -R 2d9bd612a3d2dc8f2665702baad38baa -U shaneh -Z d27048d3dae68da084505a60e1541c3b +P a074986045f1a81fb831ffee4a29af13c978b053 +R b1e893cccba0a3222ced9d709bda7393 +U drh +Z 511f68817ff94b8f1f3a0e7f5adbf2b3 diff --git a/manifest.uuid b/manifest.uuid index 1dc5ed78fb..125c6a81c5 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -a074986045f1a81fb831ffee4a29af13c978b053 \ No newline at end of file +4f7e7b44f2d17681318a1fd22466d3cc03103fc4 \ No newline at end of file diff --git a/src/util.c b/src/util.c index 7e271aac05..de73577203 100644 --- a/src/util.c +++ b/src/util.c @@ -1167,8 +1167,8 @@ void sqlite3FileSuffix3(const char *zBaseFilename, char *z){ if( zOk && sqlite3GetBoolean(zOk) ){ int i, sz; sz = sqlite3Strlen30(z); - for(i=sz-1; i>0 && z[i]!='/' && z[i]!='\\' && z[i]!='.'; i--){} - if( z[i]=='.' && sz>i+4 ) memcpy(&z[i+1], &z[sz-3], 4); + for(i=sz-1; i>0 && z[i]!='/' && z[i]!='.'; i--){} + if( z[i]=='.' && ALWAYS(sz>i+4) ) memcpy(&z[i+1], &z[sz-3], 4); } } #endif From 4aef70174bdefd062f5fc8ddab227318818858ff Mon Sep 17 00:00:00 2001 From: drh Date: Wed, 18 May 2011 03:02:10 +0000 Subject: [PATCH 38/40] Make sure the multiplexor shim uses a full pathname for temp file that it creates. FossilOrigin-Name: 186d7ff1d9804d508e472e4939608bf2be67bdc2 --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/test_multiplex.c | 7 ++++++- 3 files changed, 13 insertions(+), 8 deletions(-) diff --git a/manifest b/manifest index c9ce396096..f7a02d4dc5 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Remove\sunreachable\sbranches\sfrom\sthe\s8.3\sfilename\slogic. -D 2011-05-18T02:41:10.584 +C Make\ssure\sthe\smultiplexor\sshim\suses\sa\sfull\spathname\sfor\stemp\sfile\sthat\sit\ncreates. +D 2011-05-18T03:02:10.059 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 11dcc00a8d0e5202def00e81732784fb0cc4fe1d F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -211,7 +211,7 @@ F src/test_intarray.h 489edb9068bb926583445cb02589344961054207 F src/test_journal.c 785edd54f963aefb3c1628124170a56697c68c70 F src/test_loadext.c df586c27176e3c2cb2e099c78da67bf14379a56e F src/test_malloc.c 7ca7be34e0e09ef0ed6619544552ed95732e41f6 -F src/test_multiplex.c c71f0a0cdf2b89a441e0bcefb2fcdf1dd358a820 +F src/test_multiplex.c 8e67617b80b532315293761970589581745a52a0 F src/test_multiplex.h e99c571bc4968b7a9363b661481f3934bfead61d F src/test_mutex.c a6bd7b9cf6e19d989e31392b06ac8d189f0d573e F src/test_onefile.c 40cf9e212a377a6511469384a64b01e6e34b2eec @@ -937,7 +937,7 @@ F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224 F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e F tool/split-sqlite3c.tcl d9be87f1c340285a3e081eb19b4a247981ed290c F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f -P a074986045f1a81fb831ffee4a29af13c978b053 -R b1e893cccba0a3222ced9d709bda7393 +P 4f7e7b44f2d17681318a1fd22466d3cc03103fc4 +R d6d83dacd40319cfb494e08bc967aebf U drh -Z 511f68817ff94b8f1f3a0e7f5adbf2b3 +Z e159c1e62c6ced1398d519693948ac08 diff --git a/manifest.uuid b/manifest.uuid index 125c6a81c5..89d525c9c0 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -4f7e7b44f2d17681318a1fd22466d3cc03103fc4 \ No newline at end of file +186d7ff1d9804d508e472e4939608bf2be67bdc2 \ No newline at end of file diff --git a/src/test_multiplex.c b/src/test_multiplex.c index 861e68e877..32e63ae889 100644 --- a/src/test_multiplex.c +++ b/src/test_multiplex.c @@ -218,14 +218,19 @@ static int multiplexGetTempname(sqlite3_vfs *pOrigVfs, int nBuf, char *zBuf){ ** pVfs->mxPathname characters. */ if( pOrigVfs->mxPathname <= nBuf ){ + char *zTmp = sqlite3_malloc(pOrigVfs->mxPathname); + if( zTmp==0 ) return SQLITE_NOMEM; /* sqlite3_temp_directory should always be less than ** pVfs->mxPathname characters. */ sqlite3_snprintf(pOrigVfs->mxPathname, - zBuf, + zTmp, "%s/", sqlite3_temp_directory ? sqlite3_temp_directory : "."); + rc = pOrigVfs->xFullPathname(pOrigVfs, zTmp, nBuf, zBuf); + sqlite3_free(zTmp); + if( rc ) return rc; /* Check that the output buffer is large enough for the temporary file ** name. From 52784bd01ae1b2935c1c0374dd2403bc3f0de69a Mon Sep 17 00:00:00 2001 From: drh Date: Wed, 18 May 2011 17:15:06 +0000 Subject: [PATCH 39/40] Enable URI filenames in the command-line shell. Add a check to the beginning of the shell to make sure it is compiled with the same SQLite source and header. FossilOrigin-Name: de58cb28387f44c35b1a81bdab853cafd938c1a6 --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/shell.c | 6 ++++++ 3 files changed, 13 insertions(+), 7 deletions(-) diff --git a/manifest b/manifest index f7a02d4dc5..16faa5700b 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Make\ssure\sthe\smultiplexor\sshim\suses\sa\sfull\spathname\sfor\stemp\sfile\sthat\sit\ncreates. -D 2011-05-18T03:02:10.059 +C Enable\sURI\sfilenames\sin\sthe\scommand-line\sshell.\s\sAdd\sa\scheck\sto\sthe\nbeginning\sof\sthe\sshell\sto\smake\ssure\sit\sis\scompiled\swith\sthe\ssame\nSQLite\ssource\sand\sheader. +D 2011-05-18T17:15:06.501 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 11dcc00a8d0e5202def00e81732784fb0cc4fe1d F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -178,7 +178,7 @@ F src/random.c cd4a67b3953b88019f8cd4ccd81394a8ddfaba50 F src/resolve.c 1c0f32b64f8e3f555fe1f732f9d6f501a7f05706 F src/rowset.c 69afa95a97c524ba6faf3805e717b5b7ae85a697 F src/select.c d9d440809025a58547e39f4f268c2a296bfb56ff -F src/shell.c 72e7e176bf46d5c6518d15ac4ad6847c4bb5df79 +F src/shell.c decd04236a7ef26be5ef46d4ea963044bfad9a48 F src/sqlite.h.in 8bbf8d9bc5f1a9474a633a2de7014506f1f06b90 F src/sqlite3ext.h c90bd5507099f62043832d73f6425d8d5c5da754 F src/sqliteInt.h 771087591052966d36ac1fcd3c8bb7a8c6cf9a38 @@ -937,7 +937,7 @@ F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224 F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e F tool/split-sqlite3c.tcl d9be87f1c340285a3e081eb19b4a247981ed290c F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f -P 4f7e7b44f2d17681318a1fd22466d3cc03103fc4 -R d6d83dacd40319cfb494e08bc967aebf +P 186d7ff1d9804d508e472e4939608bf2be67bdc2 +R 45381afe8cd9a292cfb03ba775eccef4 U drh -Z e159c1e62c6ced1398d519693948ac08 +Z 8316bf531771ea80911215ce32a98e54 diff --git a/manifest.uuid b/manifest.uuid index 89d525c9c0..5de0e20c97 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -186d7ff1d9804d508e472e4939608bf2be67bdc2 \ No newline at end of file +de58cb28387f44c35b1a81bdab853cafd938c1a6 \ No newline at end of file diff --git a/src/shell.c b/src/shell.c index aab70b29db..8e9870a5a8 100644 --- a/src/shell.c +++ b/src/shell.c @@ -2649,6 +2649,7 @@ static void main_init(struct callback_data *data) { data->mode = MODE_List; memcpy(data->separator,"|", 2); data->showHeader = 0; + sqlite3_config(SQLITE_CONFIG_URI, 1); sqlite3_config(SQLITE_CONFIG_LOG, shellLog, data); sqlite3_snprintf(sizeof(mainPrompt), mainPrompt,"sqlite> "); sqlite3_snprintf(sizeof(continuePrompt), continuePrompt," ...> "); @@ -2663,6 +2664,11 @@ int main(int argc, char **argv){ int i; int rc = 0; + if( strcmp(sqlite3_sourceid(),SQLITE_SOURCE_ID)!=0 ){ + fprintf(stderr, "SQLite header and source version mismatch\n%s\n%s\n", + sqlite3_sourceid(), SQLITE_SOURCE_ID); + exit(1); + } Argv0 = argv[0]; main_init(&data); stdin_is_interactive = isatty(0); From e5a1320d73f94a600ba2c9fc70060ddbf95e8a09 Mon Sep 17 00:00:00 2001 From: drh Date: Thu, 19 May 2011 01:21:42 +0000 Subject: [PATCH 40/40] When committing a WAL transaction, make sure at least one page is written to the WAL file so that the WAL subsystem will have a page on which to set the commit flag. Ticket [2d1a5c67dfc236]. FossilOrigin-Name: 67bf1c9a888b0d84d252d6c4c754c2c51994d208 --- manifest | 13 ++++---- manifest.uuid | 2 +- src/pager.c | 10 ++++++ test/tkt-2d1a5c67d.test | 73 +++++++++++++++++++++++++++++++++++++++++ 4 files changed, 91 insertions(+), 7 deletions(-) create mode 100644 test/tkt-2d1a5c67d.test diff --git a/manifest b/manifest index 16faa5700b..a2fbca16d7 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Enable\sURI\sfilenames\sin\sthe\scommand-line\sshell.\s\sAdd\sa\scheck\sto\sthe\nbeginning\sof\sthe\sshell\sto\smake\ssure\sit\sis\scompiled\swith\sthe\ssame\nSQLite\ssource\sand\sheader. -D 2011-05-18T17:15:06.501 +C When\scommitting\sa\sWAL\stransaction,\smake\ssure\sat\sleast\sone\spage\sis\nwritten\sto\sthe\sWAL\sfile\sso\sthat\sthe\sWAL\ssubsystem\swill\shave\sa\spage\non\swhich\sto\sset\sthe\scommit\sflag.\nTicket\s[2d1a5c67dfc236]. +D 2011-05-19T01:21:42.431 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 11dcc00a8d0e5202def00e81732784fb0cc4fe1d F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -165,7 +165,7 @@ F src/os_common.h a8f95b81eca8a1ab8593d23e94f8a35f35d4078f F src/os_os2.c 4a75888ba3dfc820ad5e8177025972d74d7f2440 F src/os_unix.c 6d4a58d81ad4b782406519f3790202f330e89bb7 F src/os_win.c 218b899469e570d46eb8147c2383075f7c026230 -F src/pager.c b7fe4b8e51d51a062618c4630c40d20a1a44cb80 +F src/pager.c 4b2358556c88660a94a4560de95dd728911e00fd F src/pager.h 3f8c783de1d4706b40b1ac15b64f5f896bcc78d1 F src/parse.y 12b7ebd61ea54f0e1b1083ff69cc2c8ce9353d58 F src/pcache.c 09d38c44ab275db581f7a2f6ff8b9bc7f8c0faaa @@ -705,6 +705,7 @@ F test/threadtest2.c ace893054fa134af3fc8d6e7cfecddb8e3acefb9 F test/threadtest3.c 0ed13e09690f6204d7455fac3b0e8ece490f6eef F test/tkt-02a8e81d44.test 58494de77be2cf249228ada3f313fa399821c6ab F test/tkt-26ff0c2d1e.test 888324e751512972c6e0d1a09df740d8f5aaf660 +F test/tkt-2d1a5c67d.test 39d2368072315923021700a216379fcf23ac3a5c F test/tkt-2ea2425d34.test 1cf13e6f75d149b3209a0cb32927a82d3d79fb28 F test/tkt-31338dca7e.test 5741cd48de500347a437ba1be58c8335e83c5a5e F test/tkt-313723c356.test c47f8a9330523e6f35698bf4489bcb29609b53ac @@ -937,7 +938,7 @@ F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224 F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e F tool/split-sqlite3c.tcl d9be87f1c340285a3e081eb19b4a247981ed290c F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f -P 186d7ff1d9804d508e472e4939608bf2be67bdc2 -R 45381afe8cd9a292cfb03ba775eccef4 +P de58cb28387f44c35b1a81bdab853cafd938c1a6 +R e623b89a5e0b9474dd0884ecf24382fc U drh -Z 8316bf531771ea80911215ce32a98e54 +Z 83669a82fd950b01af57955dbca1c918 diff --git a/manifest.uuid b/manifest.uuid index 5de0e20c97..ad5e538784 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -de58cb28387f44c35b1a81bdab853cafd938c1a6 \ No newline at end of file +67bf1c9a888b0d84d252d6c4c754c2c51994d208 \ No newline at end of file diff --git a/src/pager.c b/src/pager.c index b622c7acfe..6bddd7fd1f 100644 --- a/src/pager.c +++ b/src/pager.c @@ -5747,11 +5747,21 @@ int sqlite3PagerCommitPhaseOne( }else{ if( pagerUseWal(pPager) ){ PgHdr *pList = sqlite3PcacheDirtyList(pPager->pPCache); + PgHdr *pPageOne = 0; + if( pList==0 ){ + /* Must have at least one page for the WAL commit flag. + ** Ticket [2d1a5c67dfc2363e44f29d9bbd57f] 2011-05-18 */ + rc = sqlite3PagerGet(pPager, 1, &pPageOne); + pList = pPageOne; + pList->pDirty = 0; + } + assert( pList!=0 || rc!=SQLITE_OK ); if( pList ){ rc = pagerWalFrames(pPager, pList, pPager->dbSize, 1, (pPager->fullSync ? pPager->syncFlags : 0) ); } + sqlite3PagerUnref(pPageOne); if( rc==SQLITE_OK ){ sqlite3PcacheCleanAll(pPager->pPCache); } diff --git a/test/tkt-2d1a5c67d.test b/test/tkt-2d1a5c67d.test new file mode 100644 index 0000000000..676e60b057 --- /dev/null +++ b/test/tkt-2d1a5c67d.test @@ -0,0 +1,73 @@ +# 2011 May 19 +# +# The author disclaims copyright to this source code. In place of +# a legal notice, here is a blessing: +# +# May you do good and not evil. +# May you find forgiveness for yourself and forgive others. +# May you share freely, never taking more than you give. +# +#*********************************************************************** +# This file implements regression tests for SQLite library. Specifically, +# it tests that ticket [2d1a5c67dfc2363e44f29d9bbd57f7331851390a] has +# been resolved. +# +# +# + +set testdir [file dirname $argv0] +source $testdir/tester.tcl + +ifcapable !wal {finish_test; return} + +for {set ii 1} {$ii<=10} {incr ii} { + do_test tkt-2d1a5c67d.1.$ii { + db close + forcedelete test.db test.db-wal + sqlite3 db test.db + db eval "PRAGMA cache_size=$::ii" + db eval { + PRAGMA journal_mode=WAL; + CREATE TABLE t1(a,b); + CREATE INDEX t1b ON t1(b); + CREATE TABLE t2(x,y UNIQUE); + INSERT INTO t2 VALUES(3,4); + BEGIN; + INSERT INTO t1(a,b) VALUES(1,2); + SELECT 'A', * FROM t2 WHERE y=4; + SELECT 'B', * FROM t1; + COMMIT; + SELECT 'C', * FROM t1; + } + } {wal A 3 4 B 1 2 C 1 2} +} + +db close +forcedelete test.db test.db-wal +sqlite3 db test.db +register_wholenumber_module db +db eval { + PRAGMA journal_mode=WAL; + CREATE TABLE t1(a,b); + CREATE INDEX t1b ON t1(b); + CREATE TABLE t2(x,y); + CREATE VIRTUAL TABLE nums USING wholenumber; + INSERT INTO t2 SELECT value, randomblob(1000) FROM nums + WHERE value BETWEEN 1 AND 1000; +} + +for {set ii 1} {$ii<=10} {incr ii} { + do_test tkt-2d1a5c67d.2.$ii { + db eval "PRAGMA cache_size=$::ii" + db eval { + DELETE FROM t1; + BEGIN; + INSERT INTO t1(a,b) VALUES(1,2); + SELECT sum(length(y)) FROM t2; + COMMIT; + SELECT * FROM t1; + } + } {1000000 1 2} +} + +finish_test