From 51438a79366ef6cff5a920930ab76de401b53812 Mon Sep 17 00:00:00 2001 From: dan Date: Sat, 2 Apr 2011 17:00:47 +0000 Subject: [PATCH 1/2] Avoid returning SQLITE_NOTFOUND when the unix xSetSystemCall interface is invoked with NULL passed as the second argument, even if all the default system calls are already installed. FossilOrigin-Name: 3b91eaaa0b3c25022332ba3d1a5651848fc5d84c --- manifest | 18 +++++++++--------- manifest.uuid | 2 +- src/os_unix.c | 2 +- src/test_syscall.c | 33 ++++++++++++++++++++++++++------- test/oserror.test | 1 + test/syscall.test | 23 ++++++++++++++--------- 6 files changed, 52 insertions(+), 27 deletions(-) diff --git a/manifest b/manifest index 8411b2239f..81aef14195 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\sa\srace\scondition\sin\sOP_ParseSchema. -D 2011-04-02T09:44:43 +C Avoid\sreturning\sSQLITE_NOTFOUND\swhen\sthe\sunix\sxSetSystemCall\sinterface\sis\sinvoked\swith\sNULL\spassed\sas\sthe\ssecond\sargument,\seven\sif\sall\sthe\sdefault\ssystem\scalls\sare\salready\sinstalled. +D 2011-04-02T17:00:48 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 7a4d9524721d40ef9ee26f93f9bd6a51dba106f2 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -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 a3b4cdf50a9c9be8b50dc4932354ab749962a07f +F src/os_unix.c 32414676594a0a26cfccd7e02656230a3406eee7 F src/os_win.c 24d72407a90551969744cf9bcbb1b4c72c5fa845 F src/pager.c 6aa906b60a59664ba58d3f746164bb010d407ce1 F src/pager.h 3f8c783de1d4706b40b1ac15b64f5f896bcc78d1 @@ -222,7 +222,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 61bb14684142a19c580a13b4dde680044d37e0f5 +F src/test_syscall.c 34ce1be806cd180e241bc688ae3762e5e7825bda F src/test_tclvar.c f4dc67d5f780707210d6bb0eb6016a431c04c7fa F src/test_thread.c bedd05cad673dba53326f3aa468cc803038896c0 F src/test_vfs.c 2ed8853c1e51ac6f9ea091f7ce4e0d618bba8b86 @@ -594,7 +594,7 @@ F test/notnull.test cc7c78340328e6112a13c3e311a9ab3127114347 F test/null.test a8b09b8ed87852742343b33441a9240022108993 F test/omitunique.test bbb2ec4345d9125d9ee21cd9488d97a163020d5f F test/openv2.test af02ed0a9cbc0d2a61b8f35171d4d117e588e4ec -F test/oserror.test 6c61c859cd94864cfd6af83e0549e2800238c413 +F test/oserror.test 0abf1b4a935aae329b95da27388d7ca61aaea6f0 F test/pager1.test d8672fd0af5f4f9b99b06283d00f01547809bebe F test/pager2.test 745b911dde3d1f24ae0870bd433dfa83d7c658c1 F test/pager3.test 3856d9c80839be0668efee1b74811b1b7f7fc95f @@ -677,7 +677,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 d1dae1fee88613cf763d97ad0038d867509e0c42 +F test/syscall.test b967e1f5405bb1c9e2e223dbf7d7cd35220589a3 F test/sysfault.test c79441d88d23696fbec7b147dba98d42a04f523f F test/table.test 04ba066432430657712d167ebf28080fe878d305 F test/tableapi.test 2674633fa95d80da917571ebdd759a14d9819126 @@ -926,7 +926,7 @@ F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224 F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e F tool/split-sqlite3c.tcl d9be87f1c340285a3e081eb19b4a247981ed290c F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f -P 20afd81a4cf4d23962ec841bbd375f36a5156fb6 -R 25d34b3e2efbdd1c8e0ceadec6512306 +P 71a799b02a3b3cf2e12758dea29fd2465bbec3e1 +R 96ca391ad53fdccc5149ee67daf1eb80 U dan -Z 659aea6fa897bf521b0a686e5d197299 +Z 09bfa66b6aa34161ab06f7710f843391 diff --git a/manifest.uuid b/manifest.uuid index fa61c3c651..098e94575a 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -71a799b02a3b3cf2e12758dea29fd2465bbec3e1 \ No newline at end of file +3b91eaaa0b3c25022332ba3d1a5651848fc5d84c \ No newline at end of file diff --git a/src/os_unix.c b/src/os_unix.c index f04b6af273..67dd06fc1c 100644 --- a/src/os_unix.c +++ b/src/os_unix.c @@ -394,10 +394,10 @@ static int unixSetSystemCall( /* If no zName is given, restore all system calls to their default ** settings and return NULL */ + rc = SQLITE_OK; for(i=0; izName, -1)); + return TCL_OK; +} + static int test_syscall( void * clientData, Tcl_Interp *interp, @@ -609,13 +627,14 @@ static int test_syscall( const char *zName; Tcl_ObjCmdProc *xCmd; } aCmd[] = { - { "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 }, + { "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 }, + { "defaultvfs", test_syscall_defaultvfs }, { 0, 0 } }; int iCmd; diff --git a/test/oserror.test b/test/oserror.test index d1952a30dd..82a5d5f6ff 100644 --- a/test/oserror.test +++ b/test/oserror.test @@ -111,6 +111,7 @@ do_test 2.1.3 { } {} +test_syscall reset sqlite3_shutdown test_sqlite3_log sqlite3_initialize diff --git a/test/syscall.test b/test/syscall.test index 21295a59cf..95921bd35e 100644 --- a/test/syscall.test +++ b/test/syscall.test @@ -19,8 +19,12 @@ if {[llength [info commands test_syscall]]==0} { finish_test return } -set testprefix syscall +if {[test_syscall defaultvfs] != "unix"} { + finish_test + return +} +set testprefix syscall #------------------------------------------------------------------------- # Tests for the xSetSystemCall method. @@ -52,12 +56,14 @@ 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 +foreach s { + open close access getcwd stat fstat ftruncate + fcntl read pread write pwrite fchmod fallocate + pread64 pwrite64 +} { + if {[test_syscall exists $s]} {lappend syscall_list $s} +} +do_test 3.1 { lsort [test_syscall list] } [lsort $syscall_list] #------------------------------------------------------------------------- # This test verifies that if a call to open() fails and errno is set to @@ -245,6 +251,5 @@ foreach {tn hint size} { } $size } - - +test_syscall reset finish_test From 6412358526b0f2b80c55d7ab11482c752025ed0c Mon Sep 17 00:00:00 2001 From: drh Date: Sat, 2 Apr 2011 20:01:02 +0000 Subject: [PATCH 2/2] Change the name of the "tAttachMask" datatype to "yDbMask". FossilOrigin-Name: 3d6f2e82358c0d8c0ca04e0da20b84fc65c3f7fa --- manifest | 20 ++++++++++---------- manifest.uuid | 2 +- src/build.c | 8 ++++---- src/sqliteInt.h | 12 +++++++----- src/vdbeInt.h | 2 +- src/vdbeaux.c | 4 ++-- 6 files changed, 25 insertions(+), 23 deletions(-) diff --git a/manifest b/manifest index 81aef14195..927bd9ef71 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Avoid\sreturning\sSQLITE_NOTFOUND\swhen\sthe\sunix\sxSetSystemCall\sinterface\sis\sinvoked\swith\sNULL\spassed\sas\sthe\ssecond\sargument,\seven\sif\sall\sthe\sdefault\ssystem\scalls\sare\salready\sinstalled. -D 2011-04-02T17:00:48 +C Change\sthe\sname\sof\sthe\s"tAttachMask"\sdatatype\sto\s"yDbMask". +D 2011-04-02T20:01:02.621 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 7a4d9524721d40ef9ee26f93f9bd6a51dba106f2 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -124,7 +124,7 @@ F src/btmutex.c 96a12f50f7a17475155971a241d85ec5171573ff F src/btree.c 2b9c81ff64da339a67dda4f94c0d763627be0b67 F src/btree.h 8d36f774ec4b1d0027b8966f8c03d9a72a518c14 F src/btreeInt.h 20f73dc93b1eeb83afd7259fbc6bd7dcf2df7fe4 -F src/build.c 6c490fe14dedb094a202f559e3b29a276abffcf8 +F src/build.c 3a8c6c4b1e16798755d46e699b7fcc12b9f27b2b F src/callback.c 5069f224882cbdccd559f591271d28d7f37745bc F src/complete.c dc1d136c0feee03c2f7550bafc0d29075e36deac F src/ctime.c 52ff72f966cee3087e0138a3ec69371c22be3c01 @@ -180,7 +180,7 @@ F src/select.c d24406c45dd2442eb2eeaac413439066b149c944 F src/shell.c 9dc0b4bb59290c0a35256d278cab0f314987ad6a F src/sqlite.h.in e047f69a61d604d4f8be6cf1d1bdfc68be9ba7e5 F src/sqlite3ext.h c90bd5507099f62043832d73f6425d8d5c5da754 -F src/sqliteInt.h f8f1d00a22c98fd3f2fbc94da74eeb880879f89f +F src/sqliteInt.h d45b0b1db417d5308e3bf9c8983aaf2d06e7cd36 F src/sqliteLimit.h a17dcd3fb775d63b64a43a55c54cb282f9726f44 F src/status.c 4997380fbb915426fef9e500b4872e79c99267fc F src/table.c 2cd62736f845d82200acfa1287e33feb3c15d62e @@ -237,9 +237,9 @@ F src/util.c cd997077bad039efc0597eb027c929658f93c018 F src/vacuum.c 924bd1bcee2dfb05376f79845bd3b4cec7b54b2f F src/vdbe.c a45a6a0daf2161797d50b3b5b8a3e0e4debf2d2b F src/vdbe.h 4de0efb4b0fdaaa900cf419b35c458933ef1c6d2 -F src/vdbeInt.h e1c6254641168507d25b46affb6dfb53c782f553 +F src/vdbeInt.h 8ee9302ecc1036509956df8aceea6b0b5e0e231c F src/vdbeapi.c a09ad9164cafc505250d5dd6b69660c960f1308c -F src/vdbeaux.c 77921792f7ebae267490816deb6a9488f938fa85 +F src/vdbeaux.c 80ed78c8e1edf8918e0e404891d314aa01ccb095 F src/vdbeblob.c c3ccb7c8732858c680f442932e66ad06bb036562 F src/vdbemem.c 0498796b6ffbe45e32960d6a1f5adfb6e419883b F src/vdbetrace.c 3ba13bc32bdf16d2bdea523245fd16736bed67b5 @@ -926,7 +926,7 @@ F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224 F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e F tool/split-sqlite3c.tcl d9be87f1c340285a3e081eb19b4a247981ed290c F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f -P 71a799b02a3b3cf2e12758dea29fd2465bbec3e1 -R 96ca391ad53fdccc5149ee67daf1eb80 -U dan -Z 09bfa66b6aa34161ab06f7710f843391 +P 3b91eaaa0b3c25022332ba3d1a5651848fc5d84c +R e5d6d2ab5437a135179f043b3faf09c4 +U drh +Z cdbe2872c525d3ae3a361db4be775f20 diff --git a/manifest.uuid b/manifest.uuid index 098e94575a..6c4bffcf25 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -3b91eaaa0b3c25022332ba3d1a5651848fc5d84c \ No newline at end of file +3d6f2e82358c0d8c0ca04e0da20b84fc65c3f7fa \ No newline at end of file diff --git a/src/build.c b/src/build.c index bf3273fc84..b4528347d5 100644 --- a/src/build.c +++ b/src/build.c @@ -148,7 +148,7 @@ void sqlite3FinishCoding(Parse *pParse){ ** on each used database. */ if( pParse->cookieGoto>0 ){ - tAttachMask mask; + yDbMask mask; int iDb; sqlite3VdbeJumpHere(v, pParse->cookieGoto-1); for(iDb=0, mask=1; iDbnDb; mask<<=1, iDb++){ @@ -3444,12 +3444,12 @@ void sqlite3CodeVerifySchema(Parse *pParse, int iDb){ } if( iDb>=0 ){ sqlite3 *db = pToplevel->db; - tAttachMask mask; + yDbMask mask; assert( iDbnDb ); assert( db->aDb[iDb].pBt!=0 || iDb==1 ); assert( iDbcookieMask & mask)==0 ){ pToplevel->cookieMask |= mask; pToplevel->cookieValue[iDb] = db->aDb[iDb].pSchema->schema_cookie; @@ -3476,7 +3476,7 @@ void sqlite3CodeVerifySchema(Parse *pParse, int iDb){ void sqlite3BeginWriteOperation(Parse *pParse, int setStatement, int iDb){ Parse *pToplevel = sqlite3ParseToplevel(pParse); sqlite3CodeVerifySchema(pParse, iDb); - pToplevel->writeMask |= ((tAttachMask)1)<writeMask |= ((yDbMask)1)<isMultiWrite |= setStatement; } diff --git a/src/sqliteInt.h b/src/sqliteInt.h index 0825af4cdf..ba5552dba4 100644 --- a/src/sqliteInt.h +++ b/src/sqliteInt.h @@ -2125,11 +2125,13 @@ struct TriggerPrg { TriggerPrg *pNext; /* Next entry in Parse.pTriggerPrg list */ }; -/* Datatype for the bitmask of all attached databases */ +/* +** The yDbMask datatype for the bitmask of all attached databases. +*/ #if SQLITE_MAX_ATTACHED>30 - typedef sqlite3_uint64 tAttachMask; + typedef sqlite3_uint64 yDbMask; #else - typedef unsigned int tAttachMask; + typedef unsigned int yDbMask; #endif /* @@ -2180,8 +2182,8 @@ struct Parse { int iReg; /* Reg with value of this column. 0 means none. */ int lru; /* Least recently used entry has the smallest value */ } aColCache[SQLITE_N_COLCACHE]; /* One for each column cache entry */ - tAttachMask writeMask; /* Start a write transaction on these databases */ - tAttachMask cookieMask; /* Bitmask of schema verified databases */ + yDbMask writeMask; /* Start a write transaction on these databases */ + yDbMask cookieMask; /* Bitmask of schema verified databases */ u8 isMultiWrite; /* True if statement may affect/insert multiple rows */ u8 mayAbort; /* True if statement may throw an ABORT exception */ int cookieGoto; /* Address of OP_Goto to cookie verifier subroutine */ diff --git a/src/vdbeInt.h b/src/vdbeInt.h index 65cda0bcc5..5b361b5055 100644 --- a/src/vdbeInt.h +++ b/src/vdbeInt.h @@ -302,7 +302,7 @@ struct Vdbe { u8 readOnly; /* True for read-only statements */ u8 isPrepareV2; /* True if prepared with prepare_v2() */ int nChange; /* Number of db changes made since last reset */ - tAttachMask btreeMask; /* Bitmask of db->aDb[] entries referenced */ + yDbMask btreeMask; /* Bitmask of db->aDb[] entries referenced */ int iStatement; /* Statement number (or 0 if has not opened stmt) */ int aCounter[3]; /* Counters used by sqlite3_stmt_status() */ BtreeMutexArray aMutex; /* An array of Btree used here and needing locks */ diff --git a/src/vdbeaux.c b/src/vdbeaux.c index 7cab12f78d..16d234dd08 100644 --- a/src/vdbeaux.c +++ b/src/vdbeaux.c @@ -951,8 +951,8 @@ static char *displayP4(Op *pOp, char *zTemp, int nTemp){ ** in order (and released in reverse order) to avoid deadlocks. */ void sqlite3VdbeUsesBtree(Vdbe *p, int i){ - tAttachMask mask; - assert( i>=0 && idb->nDb && i=0 && idb->nDb && ibtreeMask)*8 ); mask = ((u32)1)<btreeMask & mask)==0 ){