SQLite

Check-in [3b91eaaa0b]
Login

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
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 3b91eaaa0b3c25022332ba3d1a5651848fc5d84c
User & Date: dan 2011-04-02 17:00:48.000
Context
2011-04-02
20:01
Change the name of the "tAttachMask" datatype to "yDbMask". (check-in: 3d6f2e8235 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: 3b91eaaa0b user: dan tags: trunk)
09:44
Fix a race condition in OP_ParseSchema. (check-in: 71a799b02a user: dan tags: trunk)
Changes
Side-by-Side Diff Ignore Whitespace Patch
Changes to src/os_unix.c.
390
391
392
393
394
395
396

397
398
399
400
401
402
403
404
405
406
407
390
391
392
393
394
395
396
397
398
399
400

401
402
403
404
405
406
407







+



-







  int rc = SQLITE_NOTFOUND;

  UNUSED_PARAMETER(pNotUsed);
  if( zName==0 ){
    /* If no zName is given, restore all system calls to their default
    ** settings and return NULL
    */
    rc = SQLITE_OK;
    for(i=0; i<sizeof(aSyscall)/sizeof(aSyscall[0]); i++){
      if( aSyscall[i].pDefault ){
        aSyscall[i].pCurrent = aSyscall[i].pDefault;
        rc = SQLITE_OK;
      }
    }
  }else{
    /* If zName is specified, operate on only the one system call
    ** specified.
    */
    for(i=0; i<sizeof(aSyscall)/sizeof(aSyscall[0]); i++){
Changes to src/test_syscall.c.
594
595
596
597
598
599
600


















601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618








619
620
621
622
623
624
625
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629







630
631
632
633
634
635
636
637
638
639
640
641
642
643
644







+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+











-
-
-
-
-
-
-
+
+
+
+
+
+
+
+







    Tcl_ListObjAppendElement(interp, pList, Tcl_NewStringObj(zSys, -1));
  }

  Tcl_SetObjResult(interp, pList);
  Tcl_DecrRefCount(pList);
  return TCL_OK;
}

static int test_syscall_defaultvfs(
  void * clientData,
  Tcl_Interp *interp,
  int objc,
  Tcl_Obj *CONST objv[]
){
  sqlite3_vfs *pVfs; 

  if( objc!=2 ){
    Tcl_WrongNumArgs(interp, 2, objv, "");
    return TCL_ERROR;
  }

  pVfs = sqlite3_vfs_find(0);
  Tcl_SetObjResult(interp, Tcl_NewStringObj(pVfs->zName, -1));
  return TCL_OK;
}

static int test_syscall(
  void * clientData,
  Tcl_Interp *interp,
  int objc,
  Tcl_Obj *CONST objv[]
){
  struct SyscallCmd {
    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;
  int rc;

  if( objc<2 ){
    Tcl_WrongNumArgs(interp, 1, objv, "SUB-COMMAND ...");
Changes to test/oserror.test.
107
108
109
110
111
112
113

114
115
116
117
107
108
109
110
111
112
113
114
115
116
117
118







+




do_re_test 2.1.2 { lindex $::log 0 } {^os_unix.c:\d+: \(\d+\) unlink\(.*test.db-wal\) - }
do_test 2.1.3 { 
  dbh close
  forcedelete test.db-wal
} {}
  

test_syscall reset
sqlite3_shutdown
test_sqlite3_log 
sqlite3_initialize
finish_test
Changes to test/syscall.test.
15
16
17
18
19
20
21
22
23






24
25
26
27
28
29
30
15
16
17
18
19
20
21


22
23
24
25
26
27
28
29
30
31
32
33
34







-
-
+
+
+
+
+
+







source $testdir/lock_common.tcl
source $testdir/malloc_common.tcl

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.
#
do_test 1.1.1 {
  list [catch { test_syscall reset open } msg] $msg
} {0 {}}
48
49
50
51
52
53
54
55
56
57



58
59
60





61
62
63
64
65
66
67
52
53
54
55
56
57
58



59
60
61



62
63
64
65
66
67
68
69
70
71
72
73







-
-
-
+
+
+
-
-
-
+
+
+
+
+







#
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              \
foreach s {
    open close access getcwd stat fstat ftruncate
    fcntl read pread write pwrite fchmod fallocate
]
if {[test_syscall exists fallocate]} {lappend syscall_list fallocate}
do_test 3.1 { test_syscall list } $syscall_list
    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
# EINTR, the call is retried. If it succeeds, execution continues as if
# nothing happened. 
#
test_syscall reset
241
242
243
244
245
246
247
248

249
250
247
248
249
250
251
252
253

254

255







-
+
-

} {
  do_test 8.2.$tn {
    file_control_sizehint_test db main $hint
    file size test.db
  } $size
}


test_syscall reset

finish_test