Noting that:
- In src/pragma.c line 1267 can be seen that this PRAGMA
  is only expected to exist when SQLITE_OS_WIN==1
- In src/pragma.c line 149, the pragma is eliminated when
  SQLITE_OMIT_PAGER_PRAGMAS is defined. This
  looks wrong to me.
- On Cygwin, one of the functions exported from the
  dll is "sqlite3_win32_set_directory". As this function
  is only expected to work on win32, and is documented
  to accept an Unicode win32 path, this is not logical.

Therefore, I suggest to correct the
SQLITE_OMIT_PAGER_PRAGMAS check,
and eliminate the Cygwin code which handles
this pragma: Since Cygwin is supposed to
behave like UNIX, even though it uses the "win32"
VFS, there is no reason at all to support this pragma
on Cygwin.

Cygwin's current SQLite 3.8.3-1 (beta) package
already contains those suggested modifications.

Suggested patch follows.

Regards,
          Jan Nijtmans

Index: src/pragma.c
==================================================================
--- src/pragma.c
+++ src/pragma.c
@@ -144,11 +144,11 @@
   { /* zName:     */ "count_changes",
     /* ePragTyp:  */ PragTyp_FLAG,
     /* ePragFlag: */ 0,
     /* iArg:      */ SQLITE_CountRows },
 #endif
-#if !defined(SQLITE_OMIT_PAGER_PRAGMAS) && SQLITE_OS_WIN
+#if SQLITE_OS_WIN && !defined(__CYGWIN__)
   { /* zName:     */ "data_store_directory",
     /* ePragTyp:  */ PragTyp_DATA_STORE_DIRECTORY,
     /* ePragFlag: */ 0,
     /* iArg:      */ 0 },
 #endif
@@ -1262,10 +1262,10 @@
 #endif /* SQLITE_OMIT_WSD */
     }
     break;
   }

-#if SQLITE_OS_WIN
+#if SQLITE_OS_WIN && !defined(__CYGWIN__)
   /*
   **   PRAGMA data_store_directory
   **   PRAGMA data_store_directory = ""|"directory_name"
   **
Index: src/os_win.c
==================================================================
--- src/os_win.c
+++ src/os_win.c
@@ -1662,10 +1662,11 @@
   zFilenameMbcs = winUnicodeToMbcs(zTmpWide);
   sqlite3_free(zTmpWide);
   return zFilenameMbcs;
 }

+#if !defined(__CYGWIN__)
 /*
 ** This function sets the data directory or the temporary directory based on
 ** the provided arguments.  The type argument must be 1 in order to set the
 ** data directory or 2 in order to set the temporary directory.  The zValue
 ** argument is the name of the directory to use.  The return value will be
@@ -1698,10 +1699,11 @@
     *ppDirectory = zValueUtf8;
     return SQLITE_OK;
   }
   return SQLITE_ERROR;
 }
+#endif /* __CYGWIN__ */

 /*
 ** The return value of winGetLastErrorMsg
 ** is zero if the error message fits in the buffer, or non-zero
 ** otherwise (if the message was truncated).
@@ -4958,43 +4960,15 @@
   int nFull,                    /* Size of output buffer in bytes */
   char *zFull                   /* Output buffer */
 ){

 #if defined(__CYGWIN__)
+  char *zOut;
   SimulateIOError( return SQLITE_ERROR );
   UNUSED_PARAMETER(nFull);
   assert( nFull>=pVfs->mxPathname );
-  if ( sqlite3_data_directory && !winIsVerbatimPathname(zRelative) ){
-    /*
-    ** NOTE: We are dealing with a relative path name and the data
-    **       directory has been set.  Therefore, use it as the basis
-    **       for converting the relative path name to an absolute
-    **       one by prepending the data directory and a slash.
-    */
-    char *zOut = sqlite3MallocZero( pVfs->mxPathname+1 );
-    if( !zOut ){
-      return SQLITE_IOERR_NOMEM;
-    }
-    if( cygwin_conv_path(
-            (osIsNT() ? CCP_POSIX_TO_WIN_W : CCP_POSIX_TO_WIN_A) |
-            CCP_RELATIVE, zRelative, zOut, pVfs->mxPathname+1)<0 ){
-      sqlite3_free(zOut);
-      return winLogError(SQLITE_CANTOPEN_CONVPATH, (DWORD)errno,
-                         "winFullPathname1", zRelative);
-    }else{
-      char *zUtf8 = winConvertToUtf8Filename(zOut);
-      if( !zUtf8 ){
-        sqlite3_free(zOut);
-        return SQLITE_IOERR_NOMEM;
-      }
-      sqlite3_snprintf(MIN(nFull, pVfs->mxPathname), zFull, "%s%c%s",
-                       sqlite3_data_directory, winGetDirSep(), zUtf8);
-      sqlite3_free(zUtf8);
-      sqlite3_free(zOut);
-    }
-  }else{
-    char *zOut = sqlite3MallocZero( pVfs->mxPathname+1 );
+  zOut = sqlite3MallocZero( pVfs->mxPathname+1 );
     if( !zOut ){
       return SQLITE_IOERR_NOMEM;
     }
     if( cygwin_conv_path(
             (osIsNT() ? CCP_POSIX_TO_WIN_W : CCP_POSIX_TO_WIN_A),
@@ -5010,11 +4984,10 @@
       }
       sqlite3_snprintf(MIN(nFull, pVfs->mxPathname), zFull, "%s", zUtf8);
       sqlite3_free(zUtf8);
       sqlite3_free(zOut);
     }
-  }
   return SQLITE_OK;
 #endif

 #if (SQLITE_OS_WINCE || SQLITE_OS_WINRT) && !defined(__CYGWIN__)
   SimulateIOError( return SQLITE_ERROR );
_______________________________________________
sqlite-users mailing list
[email protected]
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to