From: drh Date: Thu, 3 Nov 2016 18:49:15 +0000 (+0000) Subject: Add the SQLITE_FCNTL_WIN32_GET_HANDLE file control. X-Git-Tag: version-3.15.1~2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ac0e8a198d88faf69c5e3a30a19a05954128e5e7;p=thirdparty%2Fsqlite.git Add the SQLITE_FCNTL_WIN32_GET_HANDLE file control. FossilOrigin-Name: 5221e3cc6f81d078766a607408d4e8aa3be0a90e --- diff --git a/manifest b/manifest index 392f53801b..89b2aebb47 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Increase\sthe\sversion\snumber\sto\s3.15.1. -D 2016-11-03T18:44:07.317 +C Add\sthe\sSQLITE_FCNTL_WIN32_GET_HANDLE\sfile\scontrol. +D 2016-11-03T18:49:15.740 F Makefile.in 6fd48ffcf7c2deea7499062d1f3747f986c19678 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc 5151cc64c4c05f3455f4f692ad11410a810d937f @@ -372,7 +372,7 @@ F src/os.h 8e976e59eb4ca1c0fca6d35ee803e38951cb0343 F src/os_common.h b2f4707a603e36811d9b1a13278bffd757857b85 F src/os_setup.h 0dbaea40a7d36bf311613d31342e0b99e2536586 F src/os_unix.c be9ca0f901a2b6c1bc93dc338f4863675180c189 -F src/os_win.c 520f23475f1de530c435d30b67b7b15fe90874b0 +F src/os_win.c cf90abd4e50d9f56d2c20ce8e005aff55d7bd8e9 F src/os_win.h 7b073010f1451abe501be30d12f6bc599824944a F src/pager.c b1ee3ec0e58a0f8ca090aec67b2d0c4d256d6bea F src/pager.h ec9140e5349491e561bb76aeac7a756f191191a1 @@ -389,7 +389,7 @@ F src/resolve.c 3fac1b2737ea5a724f20b921ac7e259c9be2100b F src/rowset.c 7b7e7e479212e65b723bf40128c7b36dc5afdfac F src/select.c ea3af83e2d0f245fef81ea4cf04cb730ce67f722 F src/shell.c b80396d2fadce4681397707e30078bf416e1dec2 -F src/sqlite.h.in 2683a291ed8db5228024267be6421f0de507b80e +F src/sqlite.h.in 1011de924a6a7340c74e5442cb76f7b49c134512 F src/sqlite3.rc 5121c9e10c3964d5755191c80dd1180c122fc3a8 F src/sqlite3ext.h 8648034aa702469afb553231677306cc6492a1ae F src/sqliteInt.h 8d241c2c0a1a7b6611d3e9398f41d69426da850d @@ -397,7 +397,7 @@ F src/sqliteLimit.h c0373387c287c8d0932510b5547ecde31b5da247 F src/status.c a9e66593dfb28a9e746cba7153f84d49c1ddc4b1 F src/table.c 5226df15ab9179b9ed558d89575ea0ce37b03fc9 F src/tclsqlite.c aef87dcd8cb66564d560ab48d43d19ac812a1eab -F src/test1.c 61a08ed5861f3396ea4ff83931387696b692e1f8 +F src/test1.c 1f1a399956c8730d5f7b09c729e98764f2082162 F src/test2.c b7174313e993754303a8b33c43df7c44b46857ab F src/test3.c d03f5b5da9a2410b7a91c64b0d3306ed28ab6fee F src/test4.c 18ec393bb4d0ad1de729f0b94da7267270f3d8e6 @@ -680,7 +680,7 @@ F test/expr.test 66a2c9ac34f74f036faa4092f5402c7d3162fc93 F test/extension01.test 00d13cec817f331a687a243e0e5a2d87b0e358c9 F test/extraquick.test cb254400bd42bfb777ff675356aabf3287978f79 F test/fallocate.test 3e979af17dfa7e5e9dda5eba1a696c04fa9d47f7 -F test/filectrl.test 7c13f96457435238da99aff7343ad6a3a4885787 +F test/filectrl.test c6547e6c3c4c3ef9707a0b3dc147de718135cacc F test/filefmt.test e4edbdc637ca9576ccf4337a3cce627d9df7a56c F test/fkey1.test 13e3d48236a2b9f5c5ebd232eef9b3ab682a8a2c F test/fkey2.test f3d27ecba480a348c328965d154214719bb158a9 @@ -1526,7 +1526,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P ee16fedd2006e2eb25a519edb4bda2d838e90410 -R 886cf3150444de738e3cbb5d744b0db4 +P ccdcce468f51439b353cbf723f1710ac38110b28 +Q +16039be3739b8d3b34a1e6093eaebb09e07f984b +R 1933547740ff36264301a7e9e48d5e68 U drh -Z 5f8c40684f1783373eeba1348d7052a6 +Z c1e8dec0cf9ebdae609fe6443bb3d73f diff --git a/manifest.uuid b/manifest.uuid index 6cd045034d..0e223813a8 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -ccdcce468f51439b353cbf723f1710ac38110b28 \ No newline at end of file +5221e3cc6f81d078766a607408d4e8aa3be0a90e \ No newline at end of file diff --git a/src/os_win.c b/src/os_win.c index 6224088583..2cb5f7b0c8 100644 --- a/src/os_win.c +++ b/src/os_win.c @@ -3488,6 +3488,12 @@ static int winFileControl(sqlite3_file *id, int op, void *pArg){ OSTRACE(("FCNTL file=%p, rc=SQLITE_OK\n", pFile->h)); return SQLITE_OK; } + case SQLITE_FCNTL_WIN32_GET_HANDLE: { + LPHANDLE phFile = (LPHANDLE)pArg; + *phFile = pFile->h; + OSTRACE(("FCNTL file=%p, rc=SQLITE_OK\n", pFile->h)); + return SQLITE_OK; + } #ifdef SQLITE_TEST case SQLITE_FCNTL_WIN32_SET_HANDLE: { LPHANDLE phFile = (LPHANDLE)pArg; diff --git a/src/sqlite.h.in b/src/sqlite.h.in index 778d53d3d6..8857d13326 100644 --- a/src/sqlite.h.in +++ b/src/sqlite.h.in @@ -978,6 +978,12 @@ struct sqlite3_io_methods { ** on whether or not the file has been renamed, moved, or deleted since it ** was first opened. ** +**
  • [[SQLITE_FCNTL_WIN32_GET_HANDLE]] +** The [SQLITE_FCNTL_WIN32_GET_HANDLE] opcode can be used to obtain the +** underlying native file handle associated with a file handle. This file +** control interprets its argument as a pointer to a native file handle and +** writes the resulting value there. +** **
  • [[SQLITE_FCNTL_WIN32_SET_HANDLE]] ** The [SQLITE_FCNTL_WIN32_SET_HANDLE] opcode is used for debugging. This ** opcode causes the xFileControl method to swap the file handle with the one @@ -1028,6 +1034,7 @@ struct sqlite3_io_methods { #define SQLITE_FCNTL_RBU 26 #define SQLITE_FCNTL_VFS_POINTER 27 #define SQLITE_FCNTL_JOURNAL_POINTER 28 +#define SQLITE_FCNTL_WIN32_GET_HANDLE 29 /* deprecated names */ #define SQLITE_GET_LOCKPROXYFILE SQLITE_FCNTL_GET_LOCKPROXYFILE diff --git a/src/test1.c b/src/test1.c index a7d20be45d..6c9a0ea1e6 100644 --- a/src/test1.c +++ b/src/test1.c @@ -5677,6 +5677,38 @@ static int SQLITE_TCLAPI file_control_win32_av_retry( return TCL_OK; } +/* +** tclcmd: file_control_win32_get_handle DB +** +** This TCL command runs the sqlite3_file_control interface with +** the SQLITE_FCNTL_WIN32_GET_HANDLE opcode. +*/ +static int file_control_win32_get_handle( + ClientData clientData, /* Pointer to sqlite3_enable_XXX function */ + Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ + int objc, /* Number of arguments */ + Tcl_Obj *CONST objv[] /* Command arguments */ +){ + sqlite3 *db; + int rc; + HANDLE hFile = NULL; + char z[100]; + + if( objc!=2 ){ + Tcl_AppendResult(interp, "wrong # args: should be \"", + Tcl_GetStringFromObj(objv[0], 0), " DB", 0); + return TCL_ERROR; + } + if( getDbPointer(interp, Tcl_GetString(objv[1]), &db) ){ + return TCL_ERROR; + } + rc = sqlite3_file_control(db, NULL, SQLITE_FCNTL_WIN32_GET_HANDLE, + (void*)&hFile); + sqlite3_snprintf(sizeof(z), z, "%d %p", rc, (void*)hFile); + Tcl_AppendResult(interp, z, (char*)0); + return TCL_OK; +} + /* ** tclcmd: file_control_win32_set_handle DB HANDLE ** @@ -7441,6 +7473,7 @@ int Sqlitetest1_Init(Tcl_Interp *interp){ { "file_control_sizehint_test", file_control_sizehint_test, 0 }, #if SQLITE_OS_WIN { "file_control_win32_av_retry", file_control_win32_av_retry, 0 }, + { "file_control_win32_get_handle", file_control_win32_get_handle, 0 }, { "file_control_win32_set_handle", file_control_win32_set_handle, 0 }, #endif { "file_control_persist_wal", file_control_persist_wal, 0 }, diff --git a/test/filectrl.test b/test/filectrl.test index 28fecee92f..cb46994145 100644 --- a/test/filectrl.test +++ b/test/filectrl.test @@ -43,4 +43,30 @@ do_test filectrl-1.6 { } {/etilqs_/} db close forcedelete .test_control_lockproxy.db-conch test.proxy +forcedelete test.db test2.db + +if {$tcl_platform(platform)=="windows"} { + do_test filectrl-2.1 { + sqlite3 db test2.db + set size [file size test2.db] + set handle [file_control_win32_get_handle db] + db close + forcedelete test2.db + list $size $handle [expr {$handle != 0}] + } {/^0 \{0 \d+\} 1$/} + + do_test filectrl-2.2 { + sqlite3 db test2.db + execsql { + CREATE TABLE t1(x); + INSERT INTO t1 (x) VALUES(RANDOMBLOB(1048576)); + } + set size [file size test2.db] + set handle [file_control_win32_get_handle db] + db close + forcedelete test2.db + list $size $handle [expr {$handle != 0}] + } {/^1\d+ \{0 \d+\} 1$/} +} + finish_test