From: dan Date: Tue, 29 Mar 2011 10:04:23 +0000 (+0000) Subject: Fix a problem in the unix VFS implementation of xNextSystemCall(). Also some typos... X-Git-Tag: version-3.7.6~77 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=0fd7d860818ebee27fa86b01af296a546a7f944e;p=thirdparty%2Fsqlite.git Fix a problem in the unix VFS implementation of xNextSystemCall(). Also some typos that prevent compilation when HAVE_POSIX_FALLOCATE is defined. FossilOrigin-Name: bc6cce81565b17f886478bd51500bba2ed11ec1d --- diff --git a/install-sh b/install-sh old mode 100755 new mode 100644 diff --git a/manifest b/manifest index 9fa26f2f4c..5041a0d7f0 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\sthe\sdocumentation\sfor\sthe\ssqlite3_column_*_name()\sfunctions\sto\sdescribe\nthat\sthe\sinformation\scan\sbe\sinvalidated\swhen\sa\sprepared\sstatement\sis\s\nreprepared\sby\sthe\sfirst\sinvocation\sof\san\ssqlite3_step()\sfor\sa\sparticular\nexecution\scycle. -D 2011-03-29T01:47:22.991 +C Fix\sa\sproblem\sin\sthe\sunix\sVFS\simplementation\sof\sxNextSystemCall().\sAlso\ssome\stypos\sthat\sprevent\scompilation\swhen\sHAVE_POSIX_FALLOCATE\sis\sdefined. +D 2011-03-29T10:04:23 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 27701a1653595a1f2187dc61c8117e00a6c1d50f F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -99,7 +99,7 @@ F ext/rtree/rtree_util.tcl 06aab2ed5b826545bf215fff90ecb9255a8647ea F ext/rtree/sqlite3rtree.h 1af0899c63a688e272d69d8e746f24e76f10a3f0 F ext/rtree/tkt3363.test 142ab96eded44a3615ec79fba98c7bde7d0f96de F ext/rtree/viewrtree.tcl eea6224b3553599ae665b239bd827e182b466024 -F install-sh 9d4de14ab9fb0facae2f48780b874848cbf2f895 x +F install-sh 9d4de14ab9fb0facae2f48780b874848cbf2f895 F ltmain.sh 3ff0879076df340d2e23ae905484d8c15d5fdea8 F main.mk 7e4d4d0433c9cbfd906c6451a7cc50310a8f4555 F mkdll.sh 7d09b23c05d56532e9d44a50868eb4b12ff4f74a @@ -162,7 +162,7 @@ F src/os.c 22ac61d06e72a0dac900400147333b07b13d8e1d F src/os.h 9dbed8c2b9c1f2f2ebabc09e49829d4777c26bf9 F src/os_common.h a8f95b81eca8a1ab8593d23e94f8a35f35d4078f F src/os_os2.c 2596fd2d5d0976c6c0c628d0c3c7c4e7a724f4cf -F src/os_unix.c 942a9dca5d17c599300127c88a48413e6d55666f +F src/os_unix.c 0b37759312e8adb58c0c7dab1ab8ca16957bf299 F src/os_win.c 24d72407a90551969744cf9bcbb1b4c72c5fa845 F src/pager.c 6aa906b60a59664ba58d3f746164bb010d407ce1 F src/pager.h 3f8c783de1d4706b40b1ac15b64f5f896bcc78d1 @@ -220,7 +220,7 @@ F src/test_schema.c 8c06ef9ddb240c7a0fcd31bc221a6a2aade58bf0 F src/test_server.c bbba05c144b5fc4b52ff650a4328027b3fa5fcc6 F src/test_stat.c f682704b5d1ba8e1d4e7e882a6d7922e2dcf066c F src/test_superlock.c 2b97936ca127d13962c3605dbc9a4ef269c424cd -F src/test_syscall.c 0f5131994a813d75a9e63746b08fc940bd272bdc +F src/test_syscall.c b2b3aef993253395da25d564a920014cc3673f09 F src/test_tclvar.c f4dc67d5f780707210d6bb0eb6016a431c04c7fa F src/test_thread.c bedd05cad673dba53326f3aa468cc803038896c0 F src/test_vfs.c 2ed8853c1e51ac6f9ea091f7ce4e0d618bba8b86 @@ -604,7 +604,7 @@ F test/permutations.test 5b2a4cb756ffb2407cb4743163668d1d769febb6 F test/pragma.test fdfc09067ea104a0c247a1a79d8093b56656f850 F test/pragma2.test 5364893491b9231dd170e3459bfc2e2342658b47 F test/printf.test 05970cde31b1a9f54bd75af60597be75a5c54fea -F test/progress.test 5b075c3c790c7b2a61419bc199db87aaf48b8301 +F test/progress.test 5b075c3c790c7b2a61419bc199db87aaf48b8301 x F test/ptrchng.test ef1aa72d6cf35a2bbd0869a649b744e9d84977fc F test/quick.test 1681febc928d686362d50057c642f77a02c62e57 F test/quota.test ddafe133653093eb9a99ccd6264884ae43f9c9b8 @@ -672,6 +672,7 @@ F test/subselect.test d24fd8757daf97dafd2e889c73ea4c4272dcf4e4 F test/substr.test 18f57c4ca8a598805c4d64e304c418734d843c1a F test/superlock.test 5d7a4954b0059c903f82c7b67867bc5451a7c082 F test/sync.test ded6b39d8d8ca3c0c5518516c6371b3316d3e3a3 +F test/syscall.test 2f3e4e2cf91c3b870c4eac37f62c61208a199403 F test/sysfault.test 63144f0000167f12676adccee2a0db45eb5c2314 F test/table.test 04ba066432430657712d167ebf28080fe878d305 F test/tableapi.test 2674633fa95d80da917571ebdd759a14d9819126 @@ -893,7 +894,7 @@ F tool/genfkey.test 4196a8928b78f51d54ef58e99e99401ab2f0a7e5 F tool/lemon.c dfd81a51b6e27e469ba21d01a75ddf092d429027 F tool/lempar.c 01ca97f87610d1dac6d8cd96ab109ab1130e76dc F tool/mkkeywordhash.c d2e6b4a5965e23afb80fbe74bb54648cd371f309 -F tool/mkopts.tcl 66ac10d240cc6e86abd37dc908d50382f84ff46e +F tool/mkopts.tcl 66ac10d240cc6e86abd37dc908d50382f84ff46e x F tool/mkspeedsql.tcl a1a334d288f7adfe6e996f2e712becf076745c97 F tool/mksqlite3c.tcl cf44512a48112b1ba09590548660a5a6877afdb3 F tool/mksqlite3h.tcl d76c226a5e8e1f3b5f6593bcabe5e98b3b1ec9ff @@ -918,7 +919,7 @@ F tool/speedtest2.tcl ee2149167303ba8e95af97873c575c3e0fab58ff F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224 F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f -P 0e1d20dfaeea5ab285d16aa4b8f02b61b1d2bc10 -R cf14caccad42f10a82bdbd10df31743c -U drh -Z 5694b336908347676717c22638831e0a +P 7270f80ac5dd17b979f1f790b2dfcf811866c1dc +R 667989871349daf241bf6e2f9ef88c3d +U dan +Z e094d9a9a392624fe79d654e33f9ed32 diff --git a/manifest.uuid b/manifest.uuid index cc6b41e382..96763a4275 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -7270f80ac5dd17b979f1f790b2dfcf811866c1dc \ No newline at end of file +bc6cce81565b17f886478bd51500bba2ed11ec1d \ No newline at end of file diff --git a/src/os_unix.c b/src/os_unix.c index f4e689fa9f..d958b6fc93 100644 --- a/src/os_unix.c +++ b/src/os_unix.c @@ -371,7 +371,7 @@ static struct unix_syscall { #else { "fallocate", (sqlite3_syscall_ptr)0, 0 }, #endif -#define osFallocate ((int(*)(int,off_t,off_t)aSyscall[15].pCurrent) +#define osFallocate ((int(*)(int,off_t,off_t))aSyscall[15].pCurrent) }; /* End of the overrideable system calls */ @@ -444,18 +444,16 @@ static sqlite3_syscall_ptr unixGetSystemCall( ** system call. */ static const char *unixNextSystemCall(sqlite3_vfs *p, const char *zName){ - unsigned int i; + int i = -1; UNUSED_PARAMETER(p); - if( zName==0 ){ - i = -1; - }else{ - for(i=0; i.h, buf.st_size, nSize-buf.st_size; - }while( rc<0 && errno=EINTR ); + rc = osFallocate(pFile->h, buf.st_size, nSize-buf.st_size); + }while( rc<0 && errno==EINTR ); if( rc ) return SQLITE_IOERR_WRITE; #else /* If the OS does not have posix_fallocate(), fake it. First use diff --git a/src/test_syscall.c b/src/test_syscall.c index ba70f64b50..88e1943a66 100644 --- a/src/test_syscall.c +++ b/src/test_syscall.c @@ -46,6 +46,27 @@ ** name (i.e. "EACCES"). Not all errno codes are supported. Add extra ** to the aErrno table in function test_syscall_errno() below as ** required. +** +** test_syscall reset ?SYSTEM-CALL? +** With no argument, this is an alias for the [uninstall] command. However, +** this command uses a VFS call of the form: +** +** xSetSystemCall(pVfs, 0, 0); +** +** To restore the default system calls. The [uninstall] command restores +** each system call individually by calling (i.e.): +** +** xSetSystemCall(pVfs, "open", 0); +** +** With an argument, this command attempts to reset the system call named +** by the parameter using the same method as [uninstall]. +** +** test_syscall exists SYSTEM-CALL +** Return true if the named system call exists. Or false otherwise. +** +** test_syscall list +** Return a list of all system calls. The list is constructed using +** the xNextSystemCall() VFS method. */ #include "sqlite3.h" @@ -56,6 +77,9 @@ #ifdef SQLITE_OS_UNIX +/* From test1.c */ +extern const char *sqlite3TestErrorName(int); + #include #include @@ -399,13 +423,72 @@ static int test_syscall_uninstall( pVfs = sqlite3_vfs_find(0); for(i=0; aSyscall[i].zName; i++){ if( aSyscall[i].xOrig ){ - pVfs->xSetSystemCall(pVfs, aSyscall[i].zName, aSyscall[i].xOrig); + pVfs->xSetSystemCall(pVfs, aSyscall[i].zName, 0); aSyscall[i].xOrig = 0; } } return TCL_OK; } +static int test_syscall_reset( + void * clientData, + Tcl_Interp *interp, + int objc, + Tcl_Obj *CONST objv[] +){ + sqlite3_vfs *pVfs; + int i; + int rc; + + if( objc!=2 && objc!=3 ){ + Tcl_WrongNumArgs(interp, 2, objv, ""); + return TCL_ERROR; + } + + pVfs = sqlite3_vfs_find(0); + if( objc==2 ){ + rc = pVfs->xSetSystemCall(pVfs, 0, 0); + for(i=0; aSyscall[i].zName; i++) aSyscall[i].xOrig = 0; + }else{ + int nFunc; + char *zFunc = Tcl_GetStringFromObj(objv[2], &nFunc); + rc = pVfs->xSetSystemCall(pVfs, Tcl_GetString(objv[2]), 0); + for(i=0; rc==SQLITE_OK && aSyscall[i].zName; i++){ + if( strlen(aSyscall[i].zName)!=nFunc ) continue; + if( memcmp(aSyscall[i].zName, zFunc, nFunc) ) continue; + aSyscall[i].xOrig = 0; + } + } + if( rc!=SQLITE_OK ){ + Tcl_SetObjResult(interp, Tcl_NewStringObj(sqlite3TestErrorName(rc), -1)); + return TCL_ERROR; + } + + Tcl_ResetResult(interp); + return TCL_OK; +} + +static int test_syscall_exists( + void * clientData, + Tcl_Interp *interp, + int objc, + Tcl_Obj *CONST objv[] +){ + sqlite3_vfs *pVfs; + sqlite3_syscall_ptr x; + + if( objc!=3 ){ + Tcl_WrongNumArgs(interp, 2, objv, ""); + return TCL_ERROR; + } + + pVfs = sqlite3_vfs_find(0); + x = pVfs->xGetSystemCall(pVfs, Tcl_GetString(objv[2])); + + Tcl_SetObjResult(interp, Tcl_NewBooleanObj(x!=0)); + return TCL_OK; +} + static int test_syscall_fault( void * clientData, Tcl_Interp *interp, @@ -471,6 +554,36 @@ static int test_syscall_errno( return TCL_OK; } +static int test_syscall_list( + void * clientData, + Tcl_Interp *interp, + int objc, + Tcl_Obj *CONST objv[] +){ + const char *zSys; + sqlite3_vfs *pVfs; + Tcl_Obj *pList; + + if( objc!=2 ){ + Tcl_WrongNumArgs(interp, 2, objv, ""); + return TCL_ERROR; + } + + pVfs = sqlite3_vfs_find(0); + pList = Tcl_NewObj(); + Tcl_IncrRefCount(pList); + for(zSys = pVfs->xNextSystemCall(pVfs, 0); + zSys!=0; + zSys = pVfs->xNextSystemCall(pVfs, zSys) + ){ + Tcl_ListObjAppendElement(interp, pList, Tcl_NewStringObj(zSys, -1)); + } + + Tcl_SetObjResult(interp, pList); + Tcl_DecrRefCount(pList); + return TCL_OK; +} + static int test_syscall( void * clientData, Tcl_Interp *interp, @@ -484,7 +597,10 @@ static int test_syscall( { "fault", test_syscall_fault }, { "install", test_syscall_install }, { "uninstall", test_syscall_uninstall }, + { "reset", test_syscall_reset }, { "errno", test_syscall_errno }, + { "exists", test_syscall_exists }, + { "list", test_syscall_list }, { 0, 0 } }; int iCmd; diff --git a/test/progress.test b/test/progress.test old mode 100644 new mode 100755 diff --git a/test/syscall.test b/test/syscall.test new file mode 100644 index 0000000000..a860e40ad3 --- /dev/null +++ b/test/syscall.test @@ -0,0 +1,62 @@ +# 2011 March 29 +# +# The author disclaims copyright to this source code. In place of +# a legal notice, here is a blessing: +# +# May you do good and not evil. +# May you find forgiveness for yourself and forgive others. +# May you share freely, never taking more than you give. +# +#*********************************************************************** +# + +set testdir [file dirname $argv0] +source $testdir/tester.tcl +source $testdir/lock_common.tcl +source $testdir/malloc_common.tcl + +if {[llength [info commands test_syscall]]==0} { + finish_test + return +} +set testprefix syscall + + +#------------------------------------------------------------------------- +# Tests for the xSetSystemCall method. +# +do_test 1.1.1 { + list [catch { test_syscall reset open } msg] $msg +} {0 {}} +do_test 1.1.2 { + list [catch { test_syscall reset nosuchcall } msg] $msg +} {1 SQLITE_NOTFOUND} +do_test 1.1.3 { + list [catch { test_syscall reset open } msg] $msg +} {0 {}} +do_test 1.1.4 { + list [catch { test_syscall reset ""} msg] $msg +} {1 SQLITE_NOTFOUND} + +do_test 1.2 { test_syscall reset } {} + +do_test 1.3.1 { test_syscall install {open getcwd access} } {} +do_test 1.3.2 { test_syscall reset } {} + +#------------------------------------------------------------------------- +# Tests for the xGetSystemCall method. +# +do_test 2.1.1 { test_syscall exists open } 1 +do_test 2.1.2 { test_syscall exists nosuchcall } 0 + +#------------------------------------------------------------------------- +# Tests for the xNextSystemCall method. +# +set syscall_list [list \ + open close access getcwd stat fstat ftruncate \ + fcntl read pread write pwrite fchmod \ +] +if {[test_syscall exists fallocate]} {lappend syscall_list fallocate} +do_test 3.1 { test_syscall list } $syscall_list + +finish_test diff --git a/tool/mkopts.tcl b/tool/mkopts.tcl old mode 100644 new mode 100755