As I've found that sqlite-users mailing list does not accept mail
attachments, this is the text
of my patch:

Index: sqlite3.c
===================================================================
--- sqlite3.c    (.../sqlite3.c)    (revision 36921)
+++ sqlite3.c    (.../trunk/sqlite3.c)    (revision 38206)
@@ -24480,6 +24480,18 @@
 #endif

 /*
+** Define the OS_VMS pre-processor macro to 1 if building on
+** OpenVMS, or 0 otherwise.
+*/
+#ifndef OS_VMS
+#  if defined(__VMS)
+#    define OS_VMS 1
+#  else
+#    define OS_VMS 0
+#  endif
+#endif
+
+/*
 ** These #defines should enable >2GB file support on Posix if the
 ** underlying operating system supports it.  If the OS lacks
 ** large file support, these should be no-ops.
@@ -24609,7 +24621,7 @@
   int lastErrno;                      /* The unix errno from last I/O
error */
   void *lockingContext;               /* Locking style specific state */
   UnixUnusedFd *pUnused;              /* Pre-allocated UnixUnusedFd */
-  const char *zPath;                  /* Name of the file */
+  char *zPath;                        /* Name of the file */
   unixShm *pShm;                      /* Shared memory segment information
*/
   int szChunk;                        /* Configured by FCNTL_CHUNK_SIZE */
 #if SQLITE_ENABLE_LOCKING_STYLE
@@ -24618,8 +24630,10 @@
 #if SQLITE_ENABLE_LOCKING_STYLE || defined(__APPLE__)
   unsigned fsFlags;                   /* cached details from statfs() */
 #endif
+#if OS_VXWORKS || OS_VMS
+  int isDelete;                       /* Delete on close if true */
+#endif
 #if OS_VXWORKS
-  int isDelete;                       /* Delete on close if true */
   struct vxworksFileId *pId;          /* Unique file ID */
 #endif
 #ifndef NDEBUG
@@ -26354,6 +26368,7 @@
 */
 static int closeUnixFile(sqlite3_file *id){
   unixFile *pFile = (unixFile*)id;
+  OSTRACE(("CLOSE   %-3d\n", pFile->h));
   if( pFile->h>=0 ){
     robust_close(pFile, pFile->h, __LINE__);
     pFile->h = -1;
@@ -26367,8 +26382,14 @@
     pFile->pId = 0;
   }
 #endif
-  OSTRACE(("CLOSE   %-3d\n", pFile->h));
+#if OS_VMS
+  if( pFile->isDelete && pFile->zPath!=NULL ){
+    OSTRACE(("DELETE-ON-CLOSE   %s\n", pFile->zPath));
+    osUnlink(pFile->zPath);
+  }
+#endif
   OpenCounter(-1);
+  sqlite3_free(pFile->zPath);
   sqlite3_free(pFile->pUnused);
   memset(pFile, 0, sizeof(unixFile));
   return SQLITE_OK;
@@ -29144,7 +29165,7 @@

   OSTRACE(("OPEN    %-3d %s\n", h, zFilename));
   pNew->h = h;
-  pNew->zPath = zFilename;
+  pNew->zPath = sqlite3DbStrDup(0, zFilename);
   if( memcmp(pVfs->zName,"unix-excl",10)==0 ){
     pNew->ctrlFlags = UNIXFILE_EXCL;
   }else{
@@ -29279,7 +29300,7 @@
 #endif

   pNew->lastErrno = 0;
-#if OS_VXWORKS
+#if OS_VXWORKS || OS_VMS
   if( rc!=SQLITE_OK ){
     if( h>=0 ) robust_close(pNew, h, __LINE__);
     h = -1;
@@ -29665,7 +29686,7 @@
   }

   if( isDelete ){
-#if OS_VXWORKS
+#if OS_VXWORKS || OS_VMS
     zPath = zName;
 #else
     osUnlink(zName);
@@ -29864,9 +29885,14 @@
     sqlite3_snprintf(nOut, zOut, "%s", zPath);
   }else{
     int nCwd;
-    if( osGetcwd(zOut, nOut-1)==0 ){
+    int error;
+#if OS_VMS
+    error = (0==getcwd(zOut, nOut-1, 0));
+#else
+    error = (0==osGetcwd(zOut, nOut-1));
+#endif
+    if ( error )
       return unixLogError(SQLITE_CANTOPEN_BKPT, "getcwd", zPath);
-    }
     nCwd = (int)strlen(zOut);
     sqlite3_snprintf(nOut-nCwd, &zOut[nCwd], "/%s", zPath);
   }
_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to