/ Changes On Branch win32GetHandle
Login

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

Changes In Branch win32GetHandle Excluding Merge-Ins

This is equivalent to a diff from bcaa650e87 to b6ddabe181

2016-10-14
21:27
Add the SQLITE_FCNTL_WIN32_GET_HANDLE file control. (check-in: 16039be373 user: mistachkin tags: trunk)
2016-05-03
19:40
Minor style tweaks in the MSVC makefile. (check-in: 1b43358f89 user: mistachkin tags: trunk)
19:36
Add the experimental SQLITE_FCNTL_WIN32_GET_HANDLE file control. (Leaf check-in: b6ddabe181 user: mistachkin tags: win32GetHandle)
14:57
The session extension is disabled by default. To enable it using --enable-session on ./configure on unix and add SESSION=1 to the nmake on Windows. Or add -DSQLITE_ENABLE_SESSION and -DSQLITE_ENABLE_PREUPDATE_HOOK to build manually. (check-in: bcaa650e87 user: drh tags: trunk)
13:14
Turn the session extension off by default. Enable using --enable-session on configure scripts, or using the SESSION=1 argument to nmake on Windows. (Closed-Leaf check-in: e462cde2a5 user: drh tags: session-make)
00:04
Avoid left-shifts of signed integers. (check-in: 0715ce1643 user: drh tags: trunk)

Changes to src/os_win.c.

  3429   3429         if( a[1]>0 ){
  3430   3430           winIoerrRetryDelay = a[1];
  3431   3431         }else{
  3432   3432           a[1] = winIoerrRetryDelay;
  3433   3433         }
  3434   3434         OSTRACE(("FCNTL file=%p, rc=SQLITE_OK\n", pFile->h));
  3435   3435         return SQLITE_OK;
         3436  +    }
         3437  +    case SQLITE_FCNTL_WIN32_GET_HANDLE: {
         3438  +      LPHANDLE phFile = (LPHANDLE)pArg;
         3439  +      *phFile = pFile->h;
         3440  +      OSTRACE(("FCNTL file=%p, rc=SQLITE_OK\n", pFile->h));
         3441  +      return SQLITE_OK;
  3436   3442       }
  3437   3443   #ifdef SQLITE_TEST
  3438   3444       case SQLITE_FCNTL_WIN32_SET_HANDLE: {
  3439   3445         LPHANDLE phFile = (LPHANDLE)pArg;
  3440   3446         HANDLE hOldFile = pFile->h;
  3441   3447         pFile->h = *phFile;
  3442   3448         *phFile = hOldFile;

Changes to src/sqlite.h.in.

   961    961   ** the [SQLITE_USE_FCNTL_TRACE] compile-time option is enabled.
   962    962   **
   963    963   ** <li>[[SQLITE_FCNTL_HAS_MOVED]]
   964    964   ** The [SQLITE_FCNTL_HAS_MOVED] file control interprets its argument as a
   965    965   ** pointer to an integer and it writes a boolean into that integer depending
   966    966   ** on whether or not the file has been renamed, moved, or deleted since it
   967    967   ** was first opened.
          968  +**
          969  +** <li>[[SQLITE_FCNTL_WIN32_GET_HANDLE]]
          970  +** The [SQLITE_FCNTL_WIN32_GET_HANDLE] opcode can be used to obtain the
          971  +** underlying native file handle associated with a file handle.  This file
          972  +** control interprets its argument as a pointer to a native file handle and
          973  +** writes the resulting value there.
   968    974   **
   969    975   ** <li>[[SQLITE_FCNTL_WIN32_SET_HANDLE]]
   970    976   ** The [SQLITE_FCNTL_WIN32_SET_HANDLE] opcode is used for debugging.  This
   971    977   ** opcode causes the xFileControl method to swap the file handle with the one
   972    978   ** pointed to by the pArg argument.  This capability is used during testing
   973    979   ** and only needs to be supported when SQLITE_TEST is defined.
   974    980   **
................................................................................
  1012   1018   #define SQLITE_FCNTL_COMMIT_PHASETWO        22
  1013   1019   #define SQLITE_FCNTL_WIN32_SET_HANDLE       23
  1014   1020   #define SQLITE_FCNTL_WAL_BLOCK              24
  1015   1021   #define SQLITE_FCNTL_ZIPVFS                 25
  1016   1022   #define SQLITE_FCNTL_RBU                    26
  1017   1023   #define SQLITE_FCNTL_VFS_POINTER            27
  1018   1024   #define SQLITE_FCNTL_JOURNAL_POINTER        28
         1025  +#define SQLITE_FCNTL_WIN32_GET_HANDLE       29
  1019   1026   
  1020   1027   /* deprecated names */
  1021   1028   #define SQLITE_GET_LOCKPROXYFILE      SQLITE_FCNTL_GET_LOCKPROXYFILE
  1022   1029   #define SQLITE_SET_LOCKPROXYFILE      SQLITE_FCNTL_SET_LOCKPROXYFILE
  1023   1030   #define SQLITE_LAST_ERRNO             SQLITE_FCNTL_LAST_ERRNO
  1024   1031   
  1025   1032   

Changes to src/test1.c.

  5477   5477     if( Tcl_GetIntFromObj(interp, objv[2], &a[0]) ) return TCL_ERROR;
  5478   5478     if( Tcl_GetIntFromObj(interp, objv[3], &a[1]) ) return TCL_ERROR;
  5479   5479     rc = sqlite3_file_control(db, NULL, SQLITE_FCNTL_WIN32_AV_RETRY, (void*)a);
  5480   5480     sqlite3_snprintf(sizeof(z), z, "%d %d %d", rc, a[0], a[1]);
  5481   5481     Tcl_AppendResult(interp, z, (char*)0);
  5482   5482     return TCL_OK;  
  5483   5483   }
         5484  +
         5485  +/*
         5486  +** tclcmd:   file_control_win32_get_handle DB
         5487  +**
         5488  +** This TCL command runs the sqlite3_file_control interface with
         5489  +** the SQLITE_FCNTL_WIN32_GET_HANDLE opcode.
         5490  +*/
         5491  +static int file_control_win32_get_handle(
         5492  +  ClientData clientData, /* Pointer to sqlite3_enable_XXX function */
         5493  +  Tcl_Interp *interp,    /* The TCL interpreter that invoked this command */
         5494  +  int objc,              /* Number of arguments */
         5495  +  Tcl_Obj *CONST objv[]  /* Command arguments */
         5496  +){
         5497  +  sqlite3 *db;
         5498  +  int rc;
         5499  +  HANDLE hFile = NULL;
         5500  +  char z[100];
         5501  +
         5502  +  if( objc!=2 ){
         5503  +    Tcl_AppendResult(interp, "wrong # args: should be \"",
         5504  +        Tcl_GetStringFromObj(objv[0], 0), " DB", 0);
         5505  +    return TCL_ERROR;
         5506  +  }
         5507  +  if( getDbPointer(interp, Tcl_GetString(objv[1]), &db) ){
         5508  +    return TCL_ERROR;
         5509  +  }
         5510  +  rc = sqlite3_file_control(db, NULL, SQLITE_FCNTL_WIN32_GET_HANDLE,
         5511  +                            (void*)&hFile);
         5512  +  sqlite3_snprintf(sizeof(z), z, "%d %p", rc, (void*)hFile);
         5513  +  Tcl_AppendResult(interp, z, (char*)0);
         5514  +  return TCL_OK;  
         5515  +}
  5484   5516   
  5485   5517   /*
  5486   5518   ** tclcmd:   file_control_win32_set_handle DB HANDLE
  5487   5519   **
  5488   5520   ** This TCL command runs the sqlite3_file_control interface with
  5489   5521   ** the SQLITE_FCNTL_WIN32_SET_HANDLE opcode.
  5490   5522   */
................................................................................
  7210   7242        { "file_control_test",          file_control_test,   0   },
  7211   7243        { "file_control_lasterrno_test", file_control_lasterrno_test,  0   },
  7212   7244        { "file_control_lockproxy_test", file_control_lockproxy_test,  0   },
  7213   7245        { "file_control_chunksize_test", file_control_chunksize_test,  0   },
  7214   7246        { "file_control_sizehint_test",  file_control_sizehint_test,   0   },
  7215   7247   #if SQLITE_OS_WIN
  7216   7248        { "file_control_win32_av_retry", file_control_win32_av_retry,  0   },
         7249  +     { "file_control_win32_get_handle", file_control_win32_get_handle, 0  },
  7217   7250        { "file_control_win32_set_handle", file_control_win32_set_handle, 0  },
  7218   7251   #endif
  7219   7252        { "file_control_persist_wal",    file_control_persist_wal,     0   },
  7220   7253        { "file_control_powersafe_overwrite",file_control_powersafe_overwrite,0},
  7221   7254        { "file_control_vfsname",        file_control_vfsname,         0   },
  7222   7255        { "file_control_tempfilename",   file_control_tempfilename,    0   },
  7223   7256        { "sqlite3_vfs_list",           vfs_list,     0   },

Changes to test/filectrl.test.

    39     39   do_test filectrl-1.6 {
    40     40     sqlite3 db test.db
    41     41     set fn [file_control_tempfilename db]
    42     42     set fn
    43     43   } {/etilqs_/}
    44     44   db close
    45     45   forcedelete .test_control_lockproxy.db-conch test.proxy
           46  +forcedelete test.db test2.db
           47  +
           48  +if {$tcl_platform(platform)=="windows"} {
           49  +  do_test filectrl-2.1 {
           50  +    sqlite3 db test2.db
           51  +    set size [file size test2.db]
           52  +    set handle [file_control_win32_get_handle db]
           53  +    db close
           54  +    forcedelete test2.db
           55  +    list $size $handle [expr {$handle != 0}]
           56  +  } {/^0 \{0 \d+\} 1$/}
           57  +
           58  +  do_test filectrl-2.2 {
           59  +    sqlite3 db test2.db
           60  +    execsql {
           61  +      CREATE TABLE t1(x);
           62  +      INSERT INTO t1 (x) VALUES(RANDOMBLOB(1048576));
           63  +    }
           64  +    set size [file size test2.db]
           65  +    set handle [file_control_win32_get_handle db]
           66  +    db close
           67  +    forcedelete test2.db
           68  +    list $size $handle [expr {$handle != 0}]
           69  +  } {/^1\d+ \{0 \d+\} 1$/}
           70  +}
           71  +
    46     72   finish_test