/ Check-in [22089ea2]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Add sqlite3_win32_set_directory8() and sqlite3_win32_set_directory16() functions.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 22089ea2bbea93eb1da7f08344789a5455077169443e40025f053d2a117f1c08
User & Date: mistachkin 2018-05-02 03:01:50
Context
2018-05-02
08:12
Fix a problem in the xBestIndex method of the closure extension causing it to allocate non-contiguous argvIndex values in some cases (an "xBestIndex malfunction" error). check-in: 0c671507 user: dan tags: trunk
03:03
Add sqlite3_win32_set_directory8() and sqlite3_win32_set_directory16() functions. check-in: 6cf0f4e2 user: mistachkin tags: branch-3.23
03:01
Add sqlite3_win32_set_directory8() and sqlite3_win32_set_directory16() functions. check-in: 22089ea2 user: mistachkin tags: trunk
2018-05-01
18:39
The SQLITE_ALLOW_SQLITE_MASTER_INDEX compile-time option allows a CREATE INDEX statement against the sqlite_master table. Once created, the index works, and is usable by legacy instances of SQLite. check-in: 853f3163 user: drh tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/os_win.c.

  1907   1907   #ifndef SQLITE_OMIT_AUTOINIT
  1908   1908     if( sqlite3_initialize() ) return 0;
  1909   1909   #endif
  1910   1910     return winUtf8ToMbcs(zText, useAnsi);
  1911   1911   }
  1912   1912   
  1913   1913   /*
  1914         -** This function sets the data directory or the temporary directory based on
  1915         -** the provided arguments.  The type argument must be 1 in order to set the
  1916         -** data directory or 2 in order to set the temporary directory.  The zValue
  1917         -** argument is the name of the directory to use.  The return value will be
  1918         -** SQLITE_OK if successful.
         1914  +** This function is the same as sqlite3_win32_set_directory (below); however,
         1915  +** it accepts a UTF-8 string.
  1919   1916   */
  1920         -int sqlite3_win32_set_directory(
         1917  +int sqlite3_win32_set_directory8(
  1921   1918     unsigned long type, /* Identifier for directory being set or reset */
  1922         -  void *zValue        /* New value for directory being set or reset */
         1919  +  const char *zValue  /* New value for directory being set or reset */
  1923   1920   ){
  1924   1921     char **ppDirectory = 0;
  1925   1922   #ifndef SQLITE_OMIT_AUTOINIT
  1926   1923     int rc = sqlite3_initialize();
  1927   1924     if( rc ) return rc;
  1928   1925   #endif
  1929   1926     if( type==SQLITE_WIN32_DATA_DIRECTORY_TYPE ){
................................................................................
  1932   1929       ppDirectory = &sqlite3_temp_directory;
  1933   1930     }
  1934   1931     assert( !ppDirectory || type==SQLITE_WIN32_DATA_DIRECTORY_TYPE
  1935   1932             || type==SQLITE_WIN32_TEMP_DIRECTORY_TYPE
  1936   1933     );
  1937   1934     assert( !ppDirectory || sqlite3MemdebugHasType(*ppDirectory, MEMTYPE_HEAP) );
  1938   1935     if( ppDirectory ){
  1939         -    LPCWSTR zStrValue = zValue;
  1940         -    char *zValueUtf8 = 0;
  1941         -    if( zStrValue && zStrValue[0] ){
  1942         -      zValueUtf8 = winUnicodeToUtf8(zStrValue);
  1943         -      if ( zValueUtf8==0 ){
         1936  +    char *zCopy = 0;
         1937  +    if( zValue && zValue[0] ){
         1938  +      zCopy = sqlite3_mprintf("%s", zValue);
         1939  +      if ( zCopy==0 ){
  1944   1940           return SQLITE_NOMEM_BKPT;
  1945   1941         }
  1946   1942       }
  1947   1943       sqlite3_free(*ppDirectory);
  1948         -    *ppDirectory = zValueUtf8;
         1944  +    *ppDirectory = zCopy;
  1949   1945       return SQLITE_OK;
  1950   1946     }
  1951   1947     return SQLITE_ERROR;
  1952   1948   }
         1949  +
         1950  +/*
         1951  +** This function is the same as sqlite3_win32_set_directory (below); however,
         1952  +** it accepts a UTF-16 string.
         1953  +*/
         1954  +int sqlite3_win32_set_directory16(
         1955  +  unsigned long type, /* Identifier for directory being set or reset */
         1956  +  const void *zValue  /* New value for directory being set or reset */
         1957  +){
         1958  +  int rc;
         1959  +  char *zUtf8 = 0;
         1960  +  if( zValue ){
         1961  +    zUtf8 = sqlite3_win32_unicode_to_utf8(zValue);
         1962  +    if( zUtf8==0 ) return SQLITE_NOMEM_BKPT;
         1963  +  }
         1964  +  rc = sqlite3_win32_set_directory8(type, zUtf8);
         1965  +  if( zUtf8 ) sqlite3_free(zUtf8);
         1966  +  return rc;
         1967  +}
         1968  +
         1969  +/*
         1970  +** This function sets the data directory or the temporary directory based on
         1971  +** the provided arguments.  The type argument must be 1 in order to set the
         1972  +** data directory or 2 in order to set the temporary directory.  The zValue
         1973  +** argument is the name of the directory to use.  The return value will be
         1974  +** SQLITE_OK if successful.
         1975  +*/
         1976  +int sqlite3_win32_set_directory(
         1977  +  unsigned long type, /* Identifier for directory being set or reset */
         1978  +  void *zValue        /* New value for directory being set or reset */
         1979  +){
         1980  +  return sqlite3_win32_set_directory16(type, zValue);
         1981  +}
  1953   1982   
  1954   1983   /*
  1955   1984   ** The return value of winGetLastErrorMsg
  1956   1985   ** is zero if the error message fits in the buffer, or non-zero
  1957   1986   ** otherwise (if the message was truncated).
  1958   1987   */
  1959   1988   static int winGetLastErrorMsg(DWORD lastErrno, int nBuf, char *zBuf){

Changes to src/sqlite.h.in.

  5535   5535   ** should be NULL to cause the previous value to be freed via [sqlite3_free];
  5536   5536   ** a non-NULL value will be copied into memory obtained from [sqlite3_malloc]
  5537   5537   ** prior to being used.  The [sqlite3_win32_set_directory] interface returns
  5538   5538   ** [SQLITE_OK] to indicate success, [SQLITE_ERROR] if the type is unsupported,
  5539   5539   ** or [SQLITE_NOMEM] if memory could not be allocated.  The value of the
  5540   5540   ** [sqlite3_data_directory] variable is intended to act as a replacement for
  5541   5541   ** the current directory on the sub-platforms of Win32 where that concept is
  5542         -** not present, e.g. WinRT and UWP.
         5542  +** not present, e.g. WinRT and UWP.  The [sqlite3_win32_set_directory8] and
         5543  +** [sqlite3_win32_set_directory16] interfaces behave exactly the same as the
         5544  +** sqlite3_win32_set_directory interface except the string parameter must be
         5545  +** UTF-8 or UTF-16, respectively.
  5543   5546   */
  5544   5547   int sqlite3_win32_set_directory(
  5545   5548     unsigned long type, /* Identifier for directory being set or reset */
  5546   5549     void *zValue        /* New value for directory being set or reset */
  5547   5550   );
         5551  +int sqlite3_win32_set_directory8(unsigned long type, const char *zValue);
         5552  +int sqlite3_win32_set_directory16(unsigned long type, const void *zValue);
  5548   5553   
  5549   5554   /*
  5550   5555   ** CAPI3REF: Win32 Directory Types
  5551   5556   **
  5552   5557   ** These macros are only available on Windows.  They define the allowed values
  5553   5558   ** for the type argument to the [sqlite3_win32_set_directory] interface.
  5554   5559   */