]> git.ipfire.org Git - thirdparty/sqlite.git/commitdiff
Remove the xGetTempname() method from the vfs structure. Temp files are now opened...
authordanielk1977 <danielk1977@noemail.net>
Fri, 6 Jun 2008 11:11:25 +0000 (11:11 +0000)
committerdanielk1977 <danielk1977@noemail.net>
Fri, 6 Jun 2008 11:11:25 +0000 (11:11 +0000)
FossilOrigin-Name: 5173b3e816c7eb711cd21a9068bbafb9ebb7cff1

16 files changed:
manifest
manifest.uuid
src/os.c
src/os_unix.c
src/os_win.c
src/pager.c
src/pager.h
src/sqlite.h.in
src/test3.c
src/test6.c
src/test_async.c
src/test_devsym.c
src/test_onefile.c
src/test_osinst.c
src/vdbeaux.c
test/pragma.test

index 256136651f4e90436efad4185710d64400a4fa0b..c7770187738c3d3229f726d344acc3d07e1554c6 100644 (file)
--- a/manifest
+++ b/manifest
@@ -1,5 +1,5 @@
-C Reorganize\ssome\sof\sthe\scode\sthat\sdetects\sexpression\strees\swith\sa\sdepth\sgreater\sthan\sEXPR_MAX_DEPTH\sso\sthat\sthey\sare\sdetected\searlier.\sThis\sfurther\sreduces\sthe\sopportunities\sfor\sstack\soverflow.\s(CVS\s5189)
-D 2008-06-05T16:47:39
+C Remove\sthe\sxGetTempname()\smethod\sfrom\sthe\svfs\sstructure.\sTemp\sfiles\sare\snow\sopened\sby\spassing\sa\sNULL\spointer\sas\sthe\sfilename\sto\sxOpen().\s(CVS\s5190)
+D 2008-06-06T11:11:26
 F Makefile.arm-wince-mingw32ce-gcc ac5f7b2cef0cd850d6f755ba6ee4ab961b1fadf7
 F Makefile.in ce92ea8dc7adfb743757794f51c10d1b0d9c55e4
 F Makefile.linux-gcc d53183f4aa6a9192d249731c90dbdffbd2c68654
@@ -127,14 +127,14 @@ F src/mutex.h 079fa6fe9da18ceb89e79012c010594c6672addb
 F src/mutex_os2.c 2911ea96955ab6cba734cc4ad903fe76f834b39e
 F src/mutex_unix.c 466d20378a0645fea64c3f2e2669c33b7802df56
 F src/mutex_w32.c 133698096a2c4e81cd11ea6f4de7891c66f7b9f7
-F src/os.c 0f6fd93b30be56fc1bb52955aa6da2092702edaa
+F src/os.c 284abcb97ffdaf5f0b08fa4c5fe1fe93dd86b416
 F src/os.h 333a53ddaf25697577a58165e1216c6cb3ccf056
 F src/os_common.h 24525d8b7bce66c374dfc1810a6c9043f3359b60
 F src/os_os2.c 1578149e21c4eac42c7f230a6f40500846f8e781
-F src/os_unix.c bea384cc48cc03630703fbf3afbc9ee4b5442663
-F src/os_win.c 9ac4e4e9c864b16e5dd087eed5770c960a5b1f09
-F src/pager.c 912792937cba5838c4515a7a284c9f57f56d603e
-F src/pager.h 71c58cd613174a91b50ed66edad6148639aa064a
+F src/os_unix.c 067a4d5a26a49cc1bdf027cdddbc63a5a2fa13b7
+F src/os_win.c 07df9a6f40028d762db8976961589847be73564e
+F src/pager.c b07ae2a2b9800250064ab487ef704a67c7fb5c9d
+F src/pager.h 7b1de4bf2cf2d9b7b312e6ed5bc7fcc9ba9aa2a4
 F src/parse.y 8c2c3145eebe1964eb279cb3c4e502eae28bb0fa
 F src/pragma.c 70e7c865dce85fdf9df81848af2169009a56ed08
 F src/prepare.c cbc9301aba1d0fc3d05fae576f2eb667c189cb36
@@ -142,7 +142,7 @@ F src/printf.c f2d4f6c5b0ec24b643e85fe60258adad8b1f6acc
 F src/random.c 2b2db2de4ab491f5a14d3480466f8f4b5a5db74a
 F src/select.c da43ce3080112aa77863e9c570c1df19a892acb8
 F src/shell.c a12ea645271b7876c8f080146f48e20b00d367ec
-F src/sqlite.h.in 0f4f33b54824cc8077c028a85a1dbd8a3df4fa73
+F src/sqlite.h.in d60f963be07b6961037b1962a09bf172eb9d570f
 F src/sqlite3ext.h faacd0e6a81aabee0861c6d7883c9172e74ef5b3
 F src/sqliteInt.h debc576f4476cde358f3c7d8214b0c2f47b24555
 F src/sqliteLimit.h f435e728c6b620ef7312814d660a81f9356eb5c8
@@ -150,25 +150,25 @@ F src/table.c 1fa8f8113ac9cbc09ae4801c6d2a7f0af82c5822
 F src/tclsqlite.c c57e740e30bd6dda678796eed62c7f0e64689834
 F src/test1.c 736be7dea5cc126356bbb61a4b1ac5ff4fac7994
 F src/test2.c f0808cc643528b9620e4059ca9bda8346f526121
-F src/test3.c 5705fc361dd60fe830f1934841aee509c733c6a9
+F src/test3.c b5c1d1047a45af03375d66b3eec603faafa3ddc6
 F src/test4.c c2c0f5dc907f1346f5d4b65eb5799f11eb9e4071
 F src/test5.c 3a6a5717a149d7ca2e6d14f5be72cf7555d54dc4
-F src/test6.c 6f960990194a0fb2f5d0a8c0a6789b8fa612297a
+F src/test6.c 0a0304a69cfa4962a429d084c6d451ff9e4fb572
 F src/test7.c acec2256c7c2d279db5a8b5fa1a2a68fcc942c67
 F src/test8.c bfebbeed68c86bab495256390636d39d195d3f1a
 F src/test9.c 4615ef08750245a2d96aaa7cbe2fb4aff2b57acc
-F src/test_async.c b862919c8c3b5522dd0d36b0ea4f742526b505cf
+F src/test_async.c fb5ab7b54c0b4ece9e2283b9c38314ba5d40bab6
 F src/test_autoext.c 5e892ab84aece3f0428920bf46923f16ac83962a
 F src/test_btree.c c1308ba0b88ab577fa56c9e493a09829dfcded9c
 F src/test_config.c 982bba6221b854a86427ae64e9c65b313b0f6e03
-F src/test_devsym.c 3b1ae8abee3fdf658f850571227deaef5e460f4a
+F src/test_devsym.c 6012cb8e3acf812513511025a4fa5d626e0ba19b
 F src/test_func.c f4aafa10f17d52c43a64b47717265802e6e552b3
 F src/test_hexio.c 2f1122aa3f012fa0142ee3c36ce5c902a70cd12f
 F src/test_loadext.c 22065d601a18878e5542191001f0eaa5d77c0ed8
 F src/test_malloc.c 5c2c698355613d321f216ece25901be1040cc1fb
 F src/test_md5.c 28209a4e2068711b5443c33104fe41f21d160071
-F src/test_onefile.c f85394bf4a5342ed89e905b90a2d39340f60359d
-F src/test_osinst.c a681c2a3ba2d90e64abfdbbe366777613316f8ba
+F src/test_onefile.c 1f87d4a21cbfb24a7c35e4333fa0bd34d641f68d
+F src/test_osinst.c 22b0aea6cd0f087e40394ee61c2c73da485ff305
 F src/test_schema.c e3f93725f7c5b2cff84a69dc4332040dfbc8f81a
 F src/test_server.c 7e579eb9bf6fbe9cc45e84e4c74d3d06d049a825
 F src/test_tclvar.c e99b975614735553fa1c43503d85b0dd988c0e77
@@ -183,7 +183,7 @@ F src/vdbe.c 04fec4d3c89c409f52c885f5904a884a74f31666
 F src/vdbe.h 1e3722d471739c2b213c6283b60373290e52f7ea
 F src/vdbeInt.h ede1a31cfa74d4718f41da491bd1d2b3abc137fc
 F src/vdbeapi.c 22b01ed175e4d4c613ee82cabc7a44a275641206
-F src/vdbeaux.c 8ca1189489e4e415e39e5a3a1dd3dfa57b1294bb
+F src/vdbeaux.c 433be5e2fff724d3a0e086d15d5597a8ef85bb29
 F src/vdbeblob.c 554736781ee273a8089c776e96bdb53e66f57ce6
 F src/vdbefifo.c 1644a41c6366ff25a920df4ca675f12d3f559687
 F src/vdbemem.c a39a822e6ae61c4cab4a512df4a315888b206911
@@ -422,7 +422,7 @@ F test/pager2.test c025f91b75fe65e85febda64d9416428b8a5cab5
 F test/pager3.test 2323bf27fd5bd887b580247e5bce500ceee994b4
 F test/pageropt.test 6df72c441db0a037b7ec6990d16311c24fbea77b
 F test/pagesize.test e0a8b3fe80f8b8e808d94a00734c7a18c76c407e
-F test/pragma.test c3229f5f66a00807fa1d3cb8fd07d87c28c93e3e
+F test/pragma.test 6b9bee4f5dbb9bccde4d0d5caf13a33f9da86e15
 F test/pragma2.test 5364893491b9231dd170e3459bfc2e2342658b47
 F test/printf.test c3405535b418d454e8a52196a0fc592ec9eec58d
 F test/progress.test 5b075c3c790c7b2a61419bc199db87aaf48b8301 x
@@ -591,7 +591,7 @@ F tool/speedtest16.c c8a9c793df96db7e4933f0852abb7a03d48f2e81
 F tool/speedtest2.tcl ee2149167303ba8e95af97873c575c3e0fab58ff
 F tool/speedtest8.c 1dbced29de5f59ba2ebf877edcadf171540374d1
 F tool/speedtest8inst1.c c65494ca99d1e09c246dfe37a7ca7a354af9990f
-P 4226ac54beea1b58de8ab7b9d768d999f50438a6
-R 15114df36c8c1f1e10e6cc53ddf8867c
+P 16d4c53a8e4d3cfc1abac3b8bb44d8bfd9471e32
+R dc477a96e7521594f69924f7a3878189
 U danielk1977
-Z b0654222f29652b857476f2b1403ea27
+Z 6a0735c3e200d6d56eadd6bfef72f1ef
index e257adf45e6b9d1332b6123cccdbb8052e5f017a..cc8700c74766007292047816bade1993e350b3df 100644 (file)
@@ -1 +1 @@
-16d4c53a8e4d3cfc1abac3b8bb44d8bfd9471e32
\ No newline at end of file
+5173b3e816c7eb711cd21a9068bbafb9ebb7cff1
\ No newline at end of file
index 4abf630dd5f414719f71dad69bf7af8f62d02b01..834100f0755e26f4b2876ab8d32d519e0e8838ab 100644 (file)
--- a/src/os.c
+++ b/src/os.c
@@ -13,7 +13,7 @@
 ** This file contains OS interface code that is common to all
 ** architectures.
 **
-** $Id: os.c,v 1.110 2008/06/05 11:39:11 danielk1977 Exp $
+** $Id: os.c,v 1.111 2008/06/06 11:11:26 danielk1977 Exp $
 */
 #define _SQLITE_OS_C_ 1
 #include "sqliteInt.h"
@@ -127,9 +127,6 @@ int sqlite3OsAccess(
   DO_OS_MALLOC_TEST;
   return pVfs->xAccess(pVfs, zPath, flags, pResOut);
 }
-int sqlite3OsGetTempname(sqlite3_vfs *pVfs, int nBufOut, char *zBufOut){
-  return pVfs->xGetTempname(pVfs, nBufOut, zBufOut);
-}
 int sqlite3OsFullPathname(
   sqlite3_vfs *pVfs, 
   const char *zPath, 
index ae634b75bb63db40000e9969b51b4836965b849c..13c0ee25713678b628d9c58b72198e728607a1d2 100644 (file)
@@ -12,7 +12,7 @@
 **
 ** This file contains code that is specific to Unix systems.
 **
-** $Id: os_unix.c,v 1.184 2008/06/05 11:39:11 danielk1977 Exp $
+** $Id: os_unix.c,v 1.185 2008/06/06 11:11:26 danielk1977 Exp $
 */
 #include "sqliteInt.h"
 #if OS_UNIX              /* This file is used on unix only */
@@ -2185,7 +2185,7 @@ static int fillInUnixFile(
   sqlite3_file *pId,      /* Write to the unixFile structure here */
   const char *zFilename   /* Name of the file being opened */
 ){
-  sqlite3LockingStyle lockingStyle;
+  sqlite3LockingStyle lockingStyle = noLockingStyle;
   unixFile *pNew = (unixFile *)pId;
   int rc;
 
@@ -2193,24 +2193,28 @@ static int fillInUnixFile(
   fcntl(h, F_SETFD, fcntl(h, F_GETFD, 0) | FD_CLOEXEC);
 #endif
 
-  lockingStyle = sqlite3DetectLockingStyle(zFilename, h);
-  if ( lockingStyle==posixLockingStyle ){
-    enterMutex();
-    rc = findLockInfo(h, &pNew->pLock, &pNew->pOpen);
-    leaveMutex();
-    if( rc ){
-      if( dirfd>=0 ) close(dirfd);
-      close(h);
-      return rc;
+  assert( pNew->pLock==NULL );
+  assert( pNew->pOpen==NULL );
+  if( zFilename ){
+    /* If zFilename is NULL then this is a temporary file. Temporary files
+    ** are never locked or unlocked, so noLockingStyle is used for these.
+    ** The locking style used by other files is determined by 
+    ** sqlite3DetectLockingStyle().
+    */
+    lockingStyle = sqlite3DetectLockingStyle(zFilename, h);
+    if ( lockingStyle==posixLockingStyle ){
+      enterMutex();
+      rc = findLockInfo(h, &pNew->pLock, &pNew->pOpen);
+      leaveMutex();
+      if( rc ){
+        if( dirfd>=0 ) close(dirfd);
+        close(h);
+        return rc;
+      }
     }
-  } else {
-    /*  pLock and pOpen are only used for posix advisory locking */
-    pNew->pLock = NULL;
-    pNew->pOpen = NULL;
   }
 
   OSTRACE3("OPEN    %-3d %s\n", h, zFilename);    
-  pNew->dirfd = -1;
   pNew->h = h;
   pNew->dirfd = dirfd;
   SET_THREADID(pNew);
@@ -2336,6 +2340,63 @@ static int openDirectory(const char *zFilename, int *pFd){
   return (fd>=0?SQLITE_OK:SQLITE_CANTOPEN);
 }
 
+/*
+** Create a temporary file name in zBuf.  zBuf must be allocated
+** by the calling process and must be big enough to hold at least
+** pVfs->mxPathname bytes.
+*/
+static int getTempname(int nBuf, char *zBuf){
+  static const char *azDirs[] = {
+     0,
+     "/var/tmp",
+     "/usr/tmp",
+     "/tmp",
+     ".",
+  };
+  static const unsigned char zChars[] =
+    "abcdefghijklmnopqrstuvwxyz"
+    "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
+    "0123456789";
+  int i, j;
+  struct stat buf;
+  const char *zDir = ".";
+
+  /* It's odd to simulate an io-error here, but really this is just
+  ** using the io-error infrastructure to test that SQLite handles this
+  ** function failing. 
+  */
+  SimulateIOError( return SQLITE_IOERR );
+
+  azDirs[0] = sqlite3_temp_directory;
+  for(i=0; i<sizeof(azDirs)/sizeof(azDirs[0]); i++){
+    if( azDirs[i]==0 ) continue;
+    if( stat(azDirs[i], &buf) ) continue;
+    if( !S_ISDIR(buf.st_mode) ) continue;
+    if( access(azDirs[i], 07) ) continue;
+    zDir = azDirs[i];
+    break;
+  }
+
+  /* Check that the output buffer is large enough for the temporary file 
+  ** name. If it is not, return SQLITE_ERROR.
+  */
+  if( (strlen(zDir) + strlen(SQLITE_TEMP_FILE_PREFIX) + 17) >= nBuf ){
+    return SQLITE_ERROR;
+  }
+
+  do{
+    sqlite3_snprintf(nBuf-17, zBuf, "%s/"SQLITE_TEMP_FILE_PREFIX, zDir);
+    j = strlen(zBuf);
+    sqlite3_randomness(15, &zBuf[j]);
+    for(i=0; i<15; i++, j++){
+      zBuf[j] = (char)zChars[ ((unsigned char)zBuf[j])%(sizeof(zChars)-1) ];
+    }
+    zBuf[j] = 0;
+  }while( access(zBuf,0)==0 );
+  return SQLITE_OK;
+}
+
+
 /*
 ** Open the file zPath.
 ** 
@@ -2384,6 +2445,12 @@ static int unixOpen(
       (eType==SQLITE_OPEN_MASTER_JOURNAL || eType==SQLITE_OPEN_MAIN_JOURNAL)
   );
 
+  /* If argument zPath is a NULL pointer, this function is required to open
+  ** a temporary file. Use this buffer to store the file name in.
+  */
+  char zTmpname[MAX_PATHNAME+1];
+  const char *zName = zPath;
+
   /* Check the following statements are true: 
   **
   **   (a) Exactly one of the READWRITE and READONLY flags must be set, and 
@@ -2411,6 +2478,16 @@ static int unixOpen(
        || eType==SQLITE_OPEN_TRANSIENT_DB
   );
 
+  if( !zName ){
+    int rc;
+    assert(isDelete && !isOpenDirectory);
+    rc = getTempname(MAX_PATHNAME+1, zTmpname);
+    if( rc!=SQLITE_OK ){
+      return rc;
+    }
+    zName = zTmpname;
+  }
+
   if( isReadonly )  oflags |= O_RDONLY;
   if( isReadWrite ) oflags |= O_RDWR;
   if( isCreate )    oflags |= O_CREAT;
@@ -2418,7 +2495,7 @@ static int unixOpen(
   oflags |= (O_LARGEFILE|O_BINARY);
 
   memset(pFile, 0, sizeof(unixFile));
-  fd = open(zPath, oflags, isDelete?0600:SQLITE_DEFAULT_FILE_PERMISSIONS);
+  fd = open(zName, oflags, isDelete?0600:SQLITE_DEFAULT_FILE_PERMISSIONS);
   if( fd<0 && errno!=EISDIR && isReadWrite && !isExclusive ){
     /* Failed to open the file for read/write access. Try read-only. */
     flags &= ~(SQLITE_OPEN_READWRITE|SQLITE_OPEN_CREATE);
@@ -2429,7 +2506,7 @@ static int unixOpen(
     return SQLITE_CANTOPEN;
   }
   if( isDelete ){
-    unlink(zPath);
+    unlink(zName);
   }
   if( pOutFlags ){
     *pOutFlags = flags;
@@ -2503,63 +2580,6 @@ static int unixAccess(
   return SQLITE_OK;
 }
 
-/*
-** Create a temporary file name in zBuf.  zBuf must be allocated
-** by the calling process and must be big enough to hold at least
-** pVfs->mxPathname bytes.
-*/
-static int unixGetTempname(sqlite3_vfs *pVfs, int nBuf, char *zBuf){
-  static const char *azDirs[] = {
-     0,
-     "/var/tmp",
-     "/usr/tmp",
-     "/tmp",
-     ".",
-  };
-  static const unsigned char zChars[] =
-    "abcdefghijklmnopqrstuvwxyz"
-    "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
-    "0123456789";
-  int i, j;
-  struct stat buf;
-  const char *zDir = ".";
-
-  /* It's odd to simulate an io-error here, but really this is just
-  ** using the io-error infrastructure to test that SQLite handles this
-  ** function failing. 
-  */
-  SimulateIOError( return SQLITE_ERROR );
-
-  azDirs[0] = sqlite3_temp_directory;
-  for(i=0; i<sizeof(azDirs)/sizeof(azDirs[0]); i++){
-    if( azDirs[i]==0 ) continue;
-    if( stat(azDirs[i], &buf) ) continue;
-    if( !S_ISDIR(buf.st_mode) ) continue;
-    if( access(azDirs[i], 07) ) continue;
-    zDir = azDirs[i];
-    break;
-  }
-
-  /* Check that the output buffer is large enough for the temporary file 
-  ** name. If it is not, return SQLITE_ERROR.
-  */
-  if( (strlen(zDir) + strlen(SQLITE_TEMP_FILE_PREFIX) + 17) >= nBuf ){
-    return SQLITE_ERROR;
-  }
-
-  do{
-    assert( pVfs->mxPathname==MAX_PATHNAME );
-    sqlite3_snprintf(nBuf-17, zBuf, "%s/"SQLITE_TEMP_FILE_PREFIX, zDir);
-    j = strlen(zBuf);
-    sqlite3_randomness(15, &zBuf[j]);
-    for(i=0; i<15; i++, j++){
-      zBuf[j] = (char)zChars[ ((unsigned char)zBuf[j])%(sizeof(zChars)-1) ];
-    }
-    zBuf[j] = 0;
-  }while( access(zBuf,0)==0 );
-  return SQLITE_OK;
-}
-
 
 /*
 ** Turn a relative pathname into a full pathname. The relative path
@@ -2773,7 +2793,6 @@ sqlite3_vfs *sqlite3OsDefaultVfs(void){
     unixOpen,           /* xOpen */
     unixDelete,         /* xDelete */
     unixAccess,         /* xAccess */
-    unixGetTempname,    /* xGetTempName */
     unixFullPathname,   /* xFullPathname */
     unixDlOpen,         /* xDlOpen */
     unixDlError,        /* xDlError */
index b21f65705812be94b199a0479dafd84ebe9ec996..9b13628bfab8669c0d4c8e3994856c05ae927384 100644 (file)
@@ -12,7 +12,7 @@
 **
 ** This file contains code that is specific to windows.
 **
-** $Id: os_win.c,v 1.124 2008/06/05 11:39:11 danielk1977 Exp $
+** $Id: os_win.c,v 1.125 2008/06/06 11:11:26 danielk1977 Exp $
 */
 #include "sqliteInt.h"
 #if OS_WIN               /* This file is used for windows only */
@@ -1074,6 +1074,57 @@ static void *convertUtf8Filename(const char *zFilename){
   return zConverted;
 }
 
+/*
+** Create a temporary file name in zBuf.  zBuf must be big enough to
+** hold at pVfs->mxPathname characters.
+*/
+static int getTempname(int nBuf, char *zBuf){
+  static char zChars[] =
+    "abcdefghijklmnopqrstuvwxyz"
+    "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
+    "0123456789";
+  int i, j;
+  char zTempPath[MAX_PATH+1];
+  if( sqlite3_temp_directory ){
+    sqlite3_snprintf(MAX_PATH-30, zTempPath, "%s", sqlite3_temp_directory);
+  }else if( isNT() ){
+    char *zMulti;
+    WCHAR zWidePath[MAX_PATH];
+    GetTempPathW(MAX_PATH-30, zWidePath);
+    zMulti = unicodeToUtf8(zWidePath);
+    if( zMulti ){
+      sqlite3_snprintf(MAX_PATH-30, zTempPath, "%s", zMulti);
+      free(zMulti);
+    }else{
+      return SQLITE_NOMEM;
+    }
+  }else{
+    char *zUtf8;
+    char zMbcsPath[MAX_PATH];
+    GetTempPathA(MAX_PATH-30, zMbcsPath);
+    zUtf8 = mbcsToUtf8(zMbcsPath);
+    if( zUtf8 ){
+      sqlite3_snprintf(MAX_PATH-30, zTempPath, "%s", zUtf8);
+      free(zUtf8);
+    }else{
+      return SQLITE_NOMEM;
+    }
+  }
+  for(i=strlen(zTempPath); i>0 && zTempPath[i-1]=='\\'; i--){}
+  zTempPath[i] = 0;
+  sqlite3_snprintf(nBuf-30, zBuf,
+                   "%s\\"SQLITE_TEMP_FILE_PREFIX, zTempPath);
+  j = strlen(zBuf);
+  sqlite3_randomness(20, &zBuf[j]);
+  for(i=0; i<20; i++, j++){
+    zBuf[j] = (char)zChars[ ((unsigned char)zBuf[j])%(sizeof(zChars)-1) ];
+  }
+  zBuf[j] = 0;
+  OSTRACE2("TEMP FILENAME: %s\n", zBuf);
+  return SQLITE_OK; 
+}
+
+
 /*
 ** Open a file.
 */
@@ -1091,7 +1142,23 @@ static int winOpen(
   DWORD dwFlagsAndAttributes = 0;
   int isTemp;
   winFile *pFile = (winFile*)id;
-  void *zConverted = convertUtf8Filename(zName);
+  void *zConverted;                 /* Filename in OS encoding */
+  const char *zUtf8Name = zName;    /* Filename in UTF-8 encoding */
+  char zTmpname[MAX_PATH+1];        /* Buffer used to create temp filename */
+
+  /* If the second argument to this function is NULL, generate a 
+  ** temporary file name to use 
+  */
+  if( !zUtf8Name ){
+    int rc = getTempname(MAX_PATH+1, zTmpname);
+    if( rc!=SQLITE_OK ){
+      return rc;
+    }
+    zUtf8Name = zTmpname;
+  }
+
+  /* Convert the filename to the system encoding. */
+  zConverted = convertUtf8Filename(zUtf8Name);
   if( zConverted==0 ){
     return SQLITE_NOMEM;
   }
@@ -1275,56 +1342,6 @@ static int winAccess(
 }
 
 
-/*
-** Create a temporary file name in zBuf.  zBuf must be big enough to
-** hold at pVfs->mxPathname characters.
-*/
-static int winGetTempname(sqlite3_vfs *pVfs, int nBuf, char *zBuf){
-  static char zChars[] =
-    "abcdefghijklmnopqrstuvwxyz"
-    "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
-    "0123456789";
-  int i, j;
-  char zTempPath[MAX_PATH+1];
-  if( sqlite3_temp_directory ){
-    sqlite3_snprintf(MAX_PATH-30, zTempPath, "%s", sqlite3_temp_directory);
-  }else if( isNT() ){
-    char *zMulti;
-    WCHAR zWidePath[MAX_PATH];
-    GetTempPathW(MAX_PATH-30, zWidePath);
-    zMulti = unicodeToUtf8(zWidePath);
-    if( zMulti ){
-      sqlite3_snprintf(MAX_PATH-30, zTempPath, "%s", zMulti);
-      free(zMulti);
-    }else{
-      return SQLITE_NOMEM;
-    }
-  }else{
-    char *zUtf8;
-    char zMbcsPath[MAX_PATH];
-    GetTempPathA(MAX_PATH-30, zMbcsPath);
-    zUtf8 = mbcsToUtf8(zMbcsPath);
-    if( zUtf8 ){
-      sqlite3_snprintf(MAX_PATH-30, zTempPath, "%s", zUtf8);
-      free(zUtf8);
-    }else{
-      return SQLITE_NOMEM;
-    }
-  }
-  for(i=strlen(zTempPath); i>0 && zTempPath[i-1]=='\\'; i--){}
-  zTempPath[i] = 0;
-  sqlite3_snprintf(nBuf-30, zBuf,
-                   "%s\\"SQLITE_TEMP_FILE_PREFIX, zTempPath);
-  j = strlen(zBuf);
-  sqlite3_randomness(20, &zBuf[j]);
-  for(i=0; i<20; i++, j++){
-    zBuf[j] = (char)zChars[ ((unsigned char)zBuf[j])%(sizeof(zChars)-1) ];
-  }
-  zBuf[j] = 0;
-  OSTRACE2("TEMP FILENAME: %s\n", zBuf);
-  return SQLITE_OK; 
-}
-
 /*
 ** Turn a relative pathname into a full pathname.  Write the full
 ** pathname into zOut[].  zOut[] will be at least pVfs->mxPathname
@@ -1550,7 +1567,6 @@ sqlite3_vfs *sqlite3OsDefaultVfs(void){
     winOpen,           /* xOpen */
     winDelete,         /* xDelete */
     winAccess,         /* xAccess */
-    winGetTempname,    /* xGetTempName */
     winFullPathname,   /* xFullPathname */
     winDlOpen,         /* xDlOpen */
     winDlError,        /* xDlError */
index 8cba4a37fd1d43ef32a87a54d807e53d7e5556b9..c37a755590e8e6888409d7f492c319004d97f0b6 100644 (file)
@@ -18,7 +18,7 @@
 ** file simultaneously, or one process from reading the database while
 ** another is writing.
 **
-** @(#) $Id: pager.c,v 1.452 2008/06/05 11:39:11 danielk1977 Exp $
+** @(#) $Id: pager.c,v 1.453 2008/06/06 11:11:26 danielk1977 Exp $
 */
 #ifndef SQLITE_OMIT_DISKIO
 #include "sqliteInt.h"
@@ -372,7 +372,6 @@ struct Pager {
   char *zFilename;            /* Name of the database file */
   char *zJournal;             /* Name of the journal file */
   char *zDirectory;           /* Directory hold database and journal files */
-  char *zStmtJrnl;            /* Name of the statement journal file */
   sqlite3_file *fd, *jfd;     /* File descriptors for database and journal */
   sqlite3_file *stfd;         /* File descriptor for the statement subjournal*/
   BusyHandler *pBusyHandler;  /* Pointer to sqlite.busyHandler */
@@ -2132,13 +2131,11 @@ int sqlite3_opentemp_count = 0;
 ** file when it is closed.
 */
 static int sqlite3PagerOpentemp(
-  sqlite3_vfs *pVfs,    /* The virtual file system layer */
+  Pager *pPager,        /* The pager object */
   sqlite3_file *pFile,  /* Write the file descriptor here */
-  char *zFilename,      /* Name of the file.  Might be NULL */
   int vfsFlags          /* Flags passed through to the VFS */
 ){
   int rc;
-  assert( zFilename!=0 );
 
 #ifdef SQLITE_TEST
   sqlite3_opentemp_count++;  /* Used for testing and analysis only */
@@ -2146,7 +2143,7 @@ static int sqlite3PagerOpentemp(
 
   vfsFlags |=  SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE |
             SQLITE_OPEN_EXCLUSIVE | SQLITE_OPEN_DELETEONCLOSE;
-  rc = sqlite3OsOpen(pVfs, zFilename, pFile, vfsFlags, 0);
+  rc = sqlite3OsOpen(pPager->pVfs, 0, pFile, vfsFlags, 0);
   assert( rc!=SQLITE_OK || pFile->pMethods );
   return rc;
 }
@@ -2184,21 +2181,22 @@ int sqlite3PagerOpen(
   int noReadlock = (flags & PAGER_NO_READLOCK)!=0;
   int journalFileSize = sqlite3JournalSize(pVfs);
   int nDefaultPage = SQLITE_DEFAULT_PAGE_SIZE;
-  char *zPathname;
-  int nPathname;
-  char *zStmtJrnl;
-  int nStmtJrnl;
+  char *zPathname = 0;
+  int nPathname = 0;
 
   /* The default return is a NULL pointer */
   *ppPager = 0;
 
-  /* Compute the full pathname */
-  nPathname = pVfs->mxPathname+1;
-  zPathname = sqlite3_malloc(nPathname*2);
-  if( zPathname==0 ){
-    return SQLITE_NOMEM;
-  }
+  /* Compute and store the full pathname in an allocated buffer pointed
+  ** to by zPathname, length nPathname. Or, if this is a temporary file,
+  ** leave both nPathname and zPathname set to 0.
+  */
   if( zFilename && zFilename[0] ){
+    nPathname = pVfs->mxPathname+1;
+    zPathname = sqlite3_malloc(nPathname*2);
+    if( zPathname==0 ){
+      return SQLITE_NOMEM;
+    }
 #ifndef SQLITE_OMIT_MEMORYDB
     if( strcmp(zFilename,":memory:")==0 ){
       memDb = 1;
@@ -2208,35 +2206,19 @@ int sqlite3PagerOpen(
     {
       rc = sqlite3OsFullPathname(pVfs, zFilename, nPathname, zPathname);
     }
-  }else{
-    rc = sqlite3OsGetTempname(pVfs, nPathname, zPathname);
-  }
-  if( rc!=SQLITE_OK ){
-    sqlite3_free(zPathname);
-    return rc;
-  }
-  nPathname = strlen(zPathname);
-
-  /* Put the statement journal in temporary disk space since this is
-  ** sometimes RAM disk or other optimized storage.  Unlikely the main
-  ** main journal file, the statement journal does not need to be 
-  ** colocated with the database nor does it need to be persistent.
-  */
-  zStmtJrnl = &zPathname[nPathname+1];
-  rc = sqlite3OsGetTempname(pVfs, pVfs->mxPathname+1, zStmtJrnl);
-  if( rc!=SQLITE_OK ){
-    sqlite3_free(zPathname);
-    return rc;
+    if( rc!=SQLITE_OK ){
+      sqlite3_free(zPathname);
+      return rc;
+    }
+    nPathname = strlen(zPathname);
   }
-  nStmtJrnl = strlen(zStmtJrnl);
 
   /* Allocate memory for the pager structure */
   pPager = sqlite3MallocZero(
     sizeof(*pPager) +           /* Pager structure */
     journalFileSize +           /* The journal file structure */ 
     pVfs->szOsFile * 3 +        /* The main db and two journal files */ 
-    3*nPathname + 40 +          /* zFilename, zDirectory, zJournal */
-    nStmtJrnl                   /* zStmtJrnl */
+    3*nPathname + 40            /* zFilename, zDirectory, zJournal */
   );
   if( !pPager ){
     sqlite3_free(zPathname);
@@ -2250,11 +2232,11 @@ int sqlite3PagerOpen(
   pPager->zFilename = (char*)&pPtr[pVfs->szOsFile*2+journalFileSize];
   pPager->zDirectory = &pPager->zFilename[nPathname+1];
   pPager->zJournal = &pPager->zDirectory[nPathname+1];
-  pPager->zStmtJrnl = &pPager->zJournal[nPathname+10];
   pPager->pVfs = pVfs;
-  memcpy(pPager->zFilename, zPathname, nPathname+1);
-  memcpy(pPager->zStmtJrnl, zStmtJrnl, nStmtJrnl+1);
-  sqlite3_free(zPathname);
+  if( zPathname ){
+    memcpy(pPager->zFilename, zPathname, nPathname+1);
+    sqlite3_free(zPathname);
+  }
 
   /* Open the pager file.
   */
@@ -2330,8 +2312,12 @@ int sqlite3PagerOpen(
   if( i>0 ) pPager->zDirectory[i-1] = 0;
 
   /* Fill in Pager.zJournal[] */
-  memcpy(pPager->zJournal, pPager->zFilename, nPathname);
-  memcpy(&pPager->zJournal[nPathname], "-journal", 9);
+  if( zPathname ){
+    memcpy(pPager->zJournal, pPager->zFilename, nPathname);
+    memcpy(&pPager->zJournal[nPathname], "-journal", 9);
+  }else{
+    pPager->zJournal = 0;
+  }
 
   /* pPager->journalOpen = 0; */
   pPager->useJournal = useJournal && !memDb;
@@ -3071,8 +3057,7 @@ static int pager_write_pagelist(PgHdr *pList){
     /* If the file has not yet been opened, open it now. */
     if( !pPager->fd->pMethods ){
       assert(pPager->tempFile);
-      rc = sqlite3PagerOpentemp(pPager->pVfs, pPager->fd, pPager->zFilename,
-                                pPager->vfsFlags);
+      rc = sqlite3PagerOpentemp(pPager, pPager->fd, pPager->vfsFlags);
       if( rc ) return rc;
     }
 
@@ -4961,6 +4946,9 @@ int *sqlite3PagerStats(Pager *pPager){
   a[10] = pPager->nWrite;
   return a;
 }
+int sqlite3PagerIsMemdb(Pager *pPager){
+  return MEMDB;
+}
 #endif
 
 /*
@@ -4999,8 +4987,7 @@ static int pagerStmtBegin(Pager *pPager){
   pPager->stmtHdrOff = 0;
   pPager->stmtCksum = pPager->cksumInit;
   if( !pPager->stmtOpen ){
-    rc = sqlite3PagerOpentemp(pPager->pVfs, pPager->stfd, pPager->zStmtJrnl,
-                              SQLITE_OPEN_SUBJOURNAL);
+    rc = sqlite3PagerOpentemp(pPager, pPager->stfd, SQLITE_OPEN_SUBJOURNAL);
     if( rc ){
       goto stmt_begin_failed;
     }
index 2fefea8d57c711257f7dc836d709327f8b64c518..224f55143c8f63684ce69769ae7cf241188fa9ca 100644 (file)
@@ -13,7 +13,7 @@
 ** subsystem.  The page cache subsystem reads and writes a file a page
 ** at a time and provides a journal for rollback.
 **
-** @(#) $Id: pager.h,v 1.74 2008/06/04 06:45:59 danielk1977 Exp $
+** @(#) $Id: pager.h,v 1.75 2008/06/06 11:11:26 danielk1977 Exp $
 */
 
 #ifndef _PAGER_H_
@@ -130,6 +130,7 @@ int sqlite3PagerSync(Pager *pPager);
 #ifdef SQLITE_TEST
   int *sqlite3PagerStats(Pager*);
   void sqlite3PagerRefdump(Pager*);
+  int sqlite3PagerIsMemdb(Pager*);
 #endif
 
 #ifdef SQLITE_TEST
index 610530a098aceb1255defb6729eaa8e9ef40cf72..959e9569e962d63642db36b5d766fdf34889a305 100644 (file)
@@ -30,7 +30,7 @@
 ** the version number) and changes its name to "sqlite3.h" as
 ** part of the build process.
 **
-** @(#) $Id: sqlite.h.in,v 1.320 2008/06/05 11:39:11 danielk1977 Exp $
+** @(#) $Id: sqlite.h.in,v 1.321 2008/06/06 11:11:26 danielk1977 Exp $
 */
 #ifndef _SQLITE3_H_
 #define _SQLITE3_H_
@@ -781,7 +781,7 @@ typedef struct sqlite3_mutex sqlite3_mutex;
 ** directory.
 ** 
 ** {F11150} SQLite will always allocate at least mxPathname+1 bytes for
-** the output buffers for xGetTempname and xFullPathname. {F11151} The exact
+** the output buffer xFullPathname. {F11151} The exact
 ** size of the output buffer is also passed as a parameter to both 
 ** methods. {END} If the output buffer is not large enough, [SQLITE_CANTOPEN]
 ** should be returned. As this is handled as a fatal error by SQLite,
@@ -811,7 +811,6 @@ struct sqlite3_vfs {
                int flags, int *pOutFlags);
   int (*xDelete)(sqlite3_vfs*, const char *zName, int syncDir);
   int (*xAccess)(sqlite3_vfs*, const char *zName, int flags, int *pResOut);
-  int (*xGetTempname)(sqlite3_vfs*, int nOut, char *zOut);
   int (*xFullPathname)(sqlite3_vfs*, const char *zName, int nOut, char *zOut);
   void *(*xDlOpen)(sqlite3_vfs*, const char *zFilename);
   void (*xDlError)(sqlite3_vfs*, int nByte, char *zErrMsg);
index b94f4a1e175089fab7d5c0f6f7b43792d8ca2138..f2381f41ec5f9900e5be90588bf0368e2b805545 100644 (file)
@@ -13,7 +13,7 @@
 ** is not included in the SQLite library.  It is used for automated
 ** testing of the SQLite library.
 **
-** $Id: test3.c,v 1.96 2008/05/27 20:17:01 shane Exp $
+** $Id: test3.c,v 1.97 2008/06/06 11:11:26 danielk1977 Exp $
 */
 #include "sqliteInt.h"
 #include "btreeInt.h"
@@ -1604,6 +1604,35 @@ static int btree_set_cache_size(
   return TCL_OK;
 }
 
+/*
+** Usage:   btree_ismemdb ID
+**
+** Return true if the B-Tree is in-memory.
+*/
+static int btree_ismemdb(
+  void *NotUsed,
+  Tcl_Interp *interp,    /* The TCL interpreter that invoked this command */
+  int argc,              /* Number of arguments */
+  const char **argv      /* Text of each argument */
+){
+  Btree *pBt;
+  int res;
+
+  if( argc!=2 ){
+    Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0],
+       " ID\"", 0);
+    return TCL_ERROR;
+  }
+  pBt = sqlite3TextToPtr(argv[1]);
+  sqlite3_mutex_enter(pBt->db->mutex);
+  sqlite3BtreeEnter(pBt);
+  res = sqlite3PagerIsMemdb(sqlite3BtreePager(pBt));
+  sqlite3BtreeLeave(pBt);
+  sqlite3_mutex_leave(pBt->db->mutex);
+  Tcl_SetObjResult(interp, Tcl_NewBooleanObj(res));
+  return SQLITE_OK;
+}
+
 
 /*
 ** Register commands with the TCL interpreter.
@@ -1654,6 +1683,7 @@ int Sqlitetest3_Init(Tcl_Interp *interp){
      { "btree_cursor_info",        (Tcl_CmdProc*)btree_cursor_info        },
      { "btree_ovfl_info",          (Tcl_CmdProc*)btree_ovfl_info          },
      { "btree_cursor_list",        (Tcl_CmdProc*)btree_cursor_list        },
+     { "btree_ismemdb",            (Tcl_CmdProc*)btree_ismemdb            },
   };
   int i;
 
index 46b6ea76ce615611e32e9611d50f5be3dce12533..8805cb80fd34c1e19ba95b121383bf6fceb30c93 100644 (file)
@@ -14,7 +14,7 @@
 ** the effect on the database file of an OS crash or power failure.  This
 ** is used to test the ability of SQLite to recover from those situations.
 **
-** $Id: test6.c,v 1.38 2008/06/05 11:39:11 danielk1977 Exp $
+** $Id: test6.c,v 1.39 2008/06/06 11:11:26 danielk1977 Exp $
 */
 #if SQLITE_TEST          /* This file is used for testing only */
 #include "sqliteInt.h"
@@ -589,10 +589,6 @@ static int cfAccess(
   sqlite3_vfs *pVfs = (sqlite3_vfs *)pCfVfs->pAppData;
   return pVfs->xAccess(pVfs, zPath, flags, pResOut);
 }
-static int cfGetTempname(sqlite3_vfs *pCfVfs, int nBufOut, char *zBufOut){
-  sqlite3_vfs *pVfs = (sqlite3_vfs *)pCfVfs->pAppData;
-  return pVfs->xGetTempname(pVfs, nBufOut, zBufOut);
-}
 static int cfFullPathname(
   sqlite3_vfs *pCfVfs, 
   const char *zPath, 
@@ -747,7 +743,6 @@ static int crashEnableCmd(
     cfOpen,               /* xOpen */
     cfDelete,             /* xDelete */
     cfAccess,             /* xAccess */
-    cfGetTempname,        /* xGetTempName */
     cfFullPathname,       /* xFullPathname */
     cfDlOpen,             /* xDlOpen */
     cfDlError,            /* xDlError */
index a2671fe68fb58f2dd99914a2280ffc60863a77ce..5c02a9fe6d865aad7074f8154e77c1da8a16826e 100644 (file)
@@ -10,7 +10,7 @@
 **
 *************************************************************************
 **
-** $Id: test_async.c,v 1.43 2008/06/05 11:39:11 danielk1977 Exp $
+** $Id: test_async.c,v 1.44 2008/06/06 11:11:26 danielk1977 Exp $
 **
 ** This file contains an example implementation of an asynchronous IO 
 ** backend for SQLite.
@@ -1167,11 +1167,6 @@ static int asyncAccess(
   return rc;
 }
 
-static int asyncGetTempname(sqlite3_vfs *pAsyncVfs, int nBufOut, char *zBufOut){
-  sqlite3_vfs *pVfs = (sqlite3_vfs *)pAsyncVfs->pAppData;
-  return pVfs->xGetTempname(pVfs, nBufOut, zBufOut);
-}
-
 /*
 ** Fill in zPathOut with the full path to the file identified by zPath.
 */
@@ -1271,7 +1266,6 @@ static sqlite3_vfs async_vfs = {
   asyncOpen,            /* xOpen */
   asyncDelete,          /* xDelete */
   asyncAccess,          /* xAccess */
-  asyncGetTempname,     /* xGetTempName */
   asyncFullPathname,    /* xFullPathname */
   asyncDlOpen,          /* xDlOpen */
   asyncDlError,         /* xDlError */
index b68994a1578e80cc82687e8507a323a8715a224c..0314804cd6377bf06be69fe6a2187e1804deb1c2 100644 (file)
@@ -14,7 +14,7 @@
 ** different device types (by overriding the return values of the 
 ** xDeviceCharacteristics() and xSectorSize() methods).
 **
-** $Id: test_devsym.c,v 1.6 2008/06/05 11:39:11 danielk1977 Exp $
+** $Id: test_devsym.c,v 1.7 2008/06/06 11:11:26 danielk1977 Exp $
 */
 #if SQLITE_TEST          /* This file is used for testing only */
 
@@ -59,7 +59,6 @@ static int devsymDeviceCharacteristics(sqlite3_file*);
 static int devsymOpen(sqlite3_vfs*, const char *, sqlite3_file*, int , int *);
 static int devsymDelete(sqlite3_vfs*, const char *zName, int syncDir);
 static int devsymAccess(sqlite3_vfs*, const char *zName, int flags, int *);
-static int devsymGetTempName(sqlite3_vfs*, int nOut, char *zOut);
 static int devsymFullPathname(sqlite3_vfs*, const char *zName, int, char *zOut);
 #ifndef SQLITE_OMIT_LOAD_EXTENSION
 static void *devsymDlOpen(sqlite3_vfs*, const char *zFilename);
@@ -81,7 +80,6 @@ static sqlite3_vfs devsym_vfs = {
   devsymOpen,               /* xOpen */
   devsymDelete,             /* xDelete */
   devsymAccess,             /* xAccess */
-  devsymGetTempName,        /* xGetTempName */
   devsymFullPathname,       /* xFullPathname */
 #ifndef SQLITE_OMIT_LOAD_EXTENSION
   devsymDlOpen,             /* xDlOpen */
@@ -264,15 +262,6 @@ static int devsymAccess(
   return sqlite3OsAccess(g.pVfs, zPath, flags, pResOut);
 }
 
-/*
-** Populate buffer zBufOut with a pathname suitable for use as a 
-** temporary file. zBufOut is guaranteed to point to a buffer of 
-** at least (DEVSYM_MAX_PATHNAME+1) bytes.
-*/
-static int devsymGetTempName(sqlite3_vfs *pVfs, int nOut, char *zBufOut){
-  return sqlite3OsGetTempname(g.pVfs, nOut, zBufOut);
-}
-
 /*
 ** Populate buffer zOut with the full canonical pathname corresponding
 ** to the pathname in zPath. zOut is guaranteed to point to a buffer
index 594d1c3030054b8f4f0ec20a27fb34e4782149b5..f93192278813ae31cd86749941eedf18f4b1e047 100644 (file)
@@ -10,7 +10,7 @@
 **
 *************************************************************************
 **
-** $Id: test_onefile.c,v 1.7 2008/06/05 11:39:11 danielk1977 Exp $
+** $Id: test_onefile.c,v 1.8 2008/06/06 11:11:26 danielk1977 Exp $
 **
 ** OVERVIEW:
 **
@@ -165,7 +165,6 @@ static int tmpDeviceCharacteristics(sqlite3_file*);
 static int fsOpen(sqlite3_vfs*, const char *, sqlite3_file*, int , int *);
 static int fsDelete(sqlite3_vfs*, const char *zName, int syncDir);
 static int fsAccess(sqlite3_vfs*, const char *zName, int flags, int *);
-static int fsGetTempname(sqlite3_vfs*, int nOut, char *zOut);
 static int fsFullPathname(sqlite3_vfs*, const char *zName, int nOut,char *zOut);
 static void *fsDlOpen(sqlite3_vfs*, const char *zFilename);
 static void fsDlError(sqlite3_vfs*, int nByte, char *zErrMsg);
@@ -194,7 +193,6 @@ static fs_vfs_t fs_vfs = {
     fsOpen,                                     /* xOpen */
     fsDelete,                                   /* xDelete */
     fsAccess,                                   /* xAccess */
-    fsGetTempname,                              /* xGetTempName */
     fsFullPathname,                             /* xFullPathname */
     fsDlOpen,                                   /* xDlOpen */
     fsDlError,                                  /* xDlError */
@@ -731,16 +729,6 @@ static int fsAccess(
   return SQLITE_OK;
 }
 
-/*
-** Populate buffer zBufOut with a pathname suitable for use as a 
-** temporary file. zBufOut is guaranteed to point to a buffer of 
-** at least (FS_MAX_PATHNAME+1) bytes.
-*/
-static int fsGetTempname(sqlite3_vfs *pVfs, int nBufOut, char *zBufOut){
-  sqlite3_vfs *pParent = ((fs_vfs_t *)pVfs)->pParent;
-  return pParent->xGetTempname(pParent, nBufOut, zBufOut);
-}
-
 /*
 ** Populate buffer zOut with the full canonical pathname corresponding
 ** to the pathname in zPath. zOut is guaranteed to point to a buffer
index 9daa52f1c19d68529ae1072661b2ee30a12b4bf3..00029142bf86ffeec45ac0e8fcfe51dcd5a2ed6f 100644 (file)
@@ -14,7 +14,7 @@
 ** adds instrumentation to all vfs and file methods. C and Tcl interfaces
 ** are provided to control the instrumentation.
 **
-** $Id: test_osinst.c,v 1.13 2008/06/05 11:39:11 danielk1977 Exp $
+** $Id: test_osinst.c,v 1.14 2008/06/06 11:11:26 danielk1977 Exp $
 */
 
 /*
@@ -173,7 +173,6 @@ static int instDeviceCharacteristics(sqlite3_file*);
 static int instOpen(sqlite3_vfs*, const char *, sqlite3_file*, int , int *);
 static int instDelete(sqlite3_vfs*, const char *zName, int syncDir);
 static int instAccess(sqlite3_vfs*, const char *zName, int flags, int *);
-static int instGetTempName(sqlite3_vfs*, int nOut, char *zOut);
 static int instFullPathname(sqlite3_vfs*, const char *zName, int, char *zOut);
 static void *instDlOpen(sqlite3_vfs*, const char *zFilename);
 static void instDlError(sqlite3_vfs*, int nByte, char *zErrMsg);
@@ -195,7 +194,6 @@ static sqlite3_vfs inst_vfs = {
   instOpen,               /* xOpen */
   instDelete,             /* xDelete */
   instAccess,             /* xAccess */
-  instGetTempName,        /* xGetTempName */
   instFullPathname,       /* xFullPathname */
   instDlOpen,             /* xDlOpen */
   instDlError,            /* xDlError */
@@ -418,17 +416,6 @@ static int instAccess(
   );
 }
 
-/*
-** Populate buffer zBufOut with a pathname suitable for use as a 
-** temporary file. zBufOut is guaranteed to point to a buffer of 
-** at least (INST_MAX_PATHNAME+1) bytes.
-*/
-static int instGetTempName(sqlite3_vfs *pVfs, int nOut, char *zBufOut){
-  OS_TIME_VFS( OS_GETTEMPNAME, 0, 0, 0, 0,
-    REALVFS(pVfs)->xGetTempname(REALVFS(pVfs), nOut, zBufOut);
-  );
-}
-
 /*
 ** Populate buffer zOut with the full canonical pathname corresponding
 ** to the pathname in zPath. zOut is guaranteed to point to a buffer
index 3e6c09d4d45897f035552efb652de63b0d7aca01..5398ec18002aa2715bc964d977d7d226fd4fbb63 100644 (file)
@@ -14,7 +14,7 @@
 ** to version 2.8.7, all this code was combined into the vdbe.c source file.
 ** But that file was getting too big so this subroutines were split out.
 **
-** $Id: vdbeaux.c,v 1.384 2008/06/05 11:39:11 danielk1977 Exp $
+** $Id: vdbeaux.c,v 1.385 2008/06/06 11:11:27 danielk1977 Exp $
 */
 #include "sqliteInt.h"
 #include <ctype.h>
@@ -1246,9 +1246,9 @@ static int vdbeCommit(sqlite3 *db){
   ** master-journal.
   **
   ** If the return value of sqlite3BtreeGetFilename() is a zero length
-  ** string, it means the main database is :memory:.  In that case we do
-  ** not support atomic multi-file commits, so use the simple case then
-  ** too.
+  ** string, it means the main database is :memory: or a temp file.  In 
+  ** that case we do not support atomic multi-file commits, so use the 
+  ** simple case then too.
   */
   if( 0==strlen(sqlite3BtreeGetFilename(db->aDb[0].pBt)) || nTrans<=1 ){
     for(i=0; rc==SQLITE_OK && i<db->nDb; i++){ 
index 330139c5248ad330062a3cdbf7fba58680859769..deffc159f6f4427044879eabf715b3ad6daa7239 100644 (file)
@@ -12,7 +12,7 @@
 #
 # This file implements tests for the PRAGMA command.
 #
-# $Id: pragma.test,v 1.60 2008/05/15 17:48:20 danielk1977 Exp $
+# $Id: pragma.test,v 1.61 2008/06/06 11:11:27 danielk1977 Exp $
 
 set testdir [file dirname $argv0]
 source $testdir/tester.tcl
@@ -822,11 +822,11 @@ proc check_temp_store {} {
   db eval {CREATE TEMP TABLE IF NOT EXISTS a(b)}
   db eval {PRAGMA database_list} {
     if {$name=="temp"} {
-      if {$file==""} {
+      set bt [btree_from_db db 1]
+      if {[btree_ismemdb $bt]} {
         return "memory"
-      } else {
-        return "disk"
       }
+      return "disk"
     }
   }
   return "unknown"