/ Check-in [3b91eaaa]
Login
SQLite training in Houston TX on 2019-11-05 (details)
Part of the 2019 Tcl Conference

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

Overview
Comment: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.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 3b91eaaa0b3c25022332ba3d1a5651848fc5d84c
User & Date: dan 2011-04-02 17:00:48
Context
2011-04-02
20:01
Change the name of the "tAttachMask" datatype to "yDbMask". check-in: 3d6f2e82 user: drh tags: trunk
17:00
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. check-in: 3b91eaaa user: dan tags: trunk
09:44
Fix a race condition in OP_ParseSchema. check-in: 71a799b0 user: dan tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/os_unix.c.

   390    390     int rc = SQLITE_NOTFOUND;
   391    391   
   392    392     UNUSED_PARAMETER(pNotUsed);
   393    393     if( zName==0 ){
   394    394       /* If no zName is given, restore all system calls to their default
   395    395       ** settings and return NULL
   396    396       */
          397  +    rc = SQLITE_OK;
   397    398       for(i=0; i<sizeof(aSyscall)/sizeof(aSyscall[0]); i++){
   398    399         if( aSyscall[i].pDefault ){
   399    400           aSyscall[i].pCurrent = aSyscall[i].pDefault;
   400         -        rc = SQLITE_OK;
   401    401         }
   402    402       }
   403    403     }else{
   404    404       /* If zName is specified, operate on only the one system call
   405    405       ** specified.
   406    406       */
   407    407       for(i=0; i<sizeof(aSyscall)/sizeof(aSyscall[0]); i++){

Changes to src/test_syscall.c.

   594    594       Tcl_ListObjAppendElement(interp, pList, Tcl_NewStringObj(zSys, -1));
   595    595     }
   596    596   
   597    597     Tcl_SetObjResult(interp, pList);
   598    598     Tcl_DecrRefCount(pList);
   599    599     return TCL_OK;
   600    600   }
          601  +
          602  +static int test_syscall_defaultvfs(
          603  +  void * clientData,
          604  +  Tcl_Interp *interp,
          605  +  int objc,
          606  +  Tcl_Obj *CONST objv[]
          607  +){
          608  +  sqlite3_vfs *pVfs; 
          609  +
          610  +  if( objc!=2 ){
          611  +    Tcl_WrongNumArgs(interp, 2, objv, "");
          612  +    return TCL_ERROR;
          613  +  }
          614  +
          615  +  pVfs = sqlite3_vfs_find(0);
          616  +  Tcl_SetObjResult(interp, Tcl_NewStringObj(pVfs->zName, -1));
          617  +  return TCL_OK;
          618  +}
   601    619   
   602    620   static int test_syscall(
   603    621     void * clientData,
   604    622     Tcl_Interp *interp,
   605    623     int objc,
   606    624     Tcl_Obj *CONST objv[]
   607    625   ){
   608    626     struct SyscallCmd {
   609    627       const char *zName;
   610    628       Tcl_ObjCmdProc *xCmd;
   611    629     } aCmd[] = {
   612         -    { "fault",     test_syscall_fault },
   613         -    { "install",   test_syscall_install },
   614         -    { "uninstall", test_syscall_uninstall },
   615         -    { "reset",     test_syscall_reset },
   616         -    { "errno",     test_syscall_errno },
   617         -    { "exists",    test_syscall_exists },
   618         -    { "list",      test_syscall_list },
          630  +    { "fault",      test_syscall_fault },
          631  +    { "install",    test_syscall_install },
          632  +    { "uninstall",  test_syscall_uninstall },
          633  +    { "reset",      test_syscall_reset },
          634  +    { "errno",      test_syscall_errno },
          635  +    { "exists",     test_syscall_exists },
          636  +    { "list",       test_syscall_list },
          637  +    { "defaultvfs", test_syscall_defaultvfs },
   619    638       { 0, 0 }
   620    639     };
   621    640     int iCmd;
   622    641     int rc;
   623    642   
   624    643     if( objc<2 ){
   625    644       Tcl_WrongNumArgs(interp, 1, objv, "SUB-COMMAND ...");

Changes to test/oserror.test.

   107    107   do_re_test 2.1.2 { lindex $::log 0 } {^os_unix.c:\d+: \(\d+\) unlink\(.*test.db-wal\) - }
   108    108   do_test 2.1.3 { 
   109    109     dbh close
   110    110     forcedelete test.db-wal
   111    111   } {}
   112    112     
   113    113   
          114  +test_syscall reset
   114    115   sqlite3_shutdown
   115    116   test_sqlite3_log 
   116    117   sqlite3_initialize
   117    118   finish_test

Changes to test/syscall.test.

    15     15   source $testdir/lock_common.tcl
    16     16   source $testdir/malloc_common.tcl
    17     17   
    18     18   if {[llength [info commands test_syscall]]==0} {
    19     19     finish_test
    20     20     return
    21     21   } 
           22  +
           23  +if {[test_syscall defaultvfs] != "unix"} {
           24  +  finish_test
           25  +  return
           26  +}
    22     27   set testprefix syscall
    23         -
    24     28   
    25     29   #-------------------------------------------------------------------------
    26     30   # Tests for the xSetSystemCall method.
    27     31   #
    28     32   do_test 1.1.1 {
    29     33     list [catch { test_syscall reset open } msg] $msg
    30     34   } {0 {}}
................................................................................
    48     52   #
    49     53   do_test 2.1.1 { test_syscall exists open } 1
    50     54   do_test 2.1.2 { test_syscall exists nosuchcall } 0
    51     55   
    52     56   #-------------------------------------------------------------------------
    53     57   # Tests for the xNextSystemCall method.
    54     58   #
    55         -set syscall_list [list                                \
    56         -    open close access getcwd stat fstat ftruncate     \
    57         -    fcntl read pread write pwrite fchmod              \
    58         -]
    59         -if {[test_syscall exists fallocate]} {lappend syscall_list fallocate}
    60         -do_test 3.1 { test_syscall list } $syscall_list
           59  +foreach s {
           60  +    open close access getcwd stat fstat ftruncate
           61  +    fcntl read pread write pwrite fchmod fallocate
           62  +    pread64 pwrite64
           63  +} {
           64  +  if {[test_syscall exists $s]} {lappend syscall_list $s}
           65  +}
           66  +do_test 3.1 { lsort [test_syscall list] } [lsort $syscall_list]
    61     67   
    62     68   #-------------------------------------------------------------------------
    63     69   # This test verifies that if a call to open() fails and errno is set to
    64     70   # EINTR, the call is retried. If it succeeds, execution continues as if
    65     71   # nothing happened. 
    66     72   #
    67     73   test_syscall reset
................................................................................
   241    247   } {
   242    248     do_test 8.2.$tn {
   243    249       file_control_sizehint_test db main $hint
   244    250       file size test.db
   245    251     } $size
   246    252   }
   247    253   
   248         -
   249         -
          254  +test_syscall reset
   250    255   finish_test