/ Check-in [8088031b]
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:Fix some problems in os_unix.c when compiled with ENABLE_LOCKING_STYLE on OSX. Also some minor issues with test scripts.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 8088031bc949bd4efb5edf33bbd1bce5700fca56
User & Date: dan 2011-04-01 09:04:37
Context
2011-04-01
11:56
In os_unix.c, do not return SQLITE_BUSY to SQLite following an error in fcntl(F_UNLCK), regardless of the value of errno. check-in: ff6dfe6e user: dan tags: trunk
09:04
Fix some problems in os_unix.c when compiled with ENABLE_LOCKING_STYLE on OSX. Also some minor issues with test scripts. check-in: 8088031b user: dan tags: trunk
02:26
Fix two compiler errors associated with non-standard compile-time options. check-in: e3bf2d5c user: drh tags: trunk
Changes
Hide Diffs Unified Diffs Show Whitespace Changes Patch

install-sh became executable.

whitespace changes only

Changes to src/os_unix.c.

1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
....
5743
5744
5745
5746
5747
5748
5749

5750

5751
5752
5753
5754
5755
5756
5757
      if( handleNFSUnlock ){
        off_t divSize = SHARED_SIZE - 1;
        
        lock.l_type = F_UNLCK;
        lock.l_whence = SEEK_SET;
        lock.l_start = SHARED_FIRST;
        lock.l_len = divSize;
        if( unixFileLock(pFile,, &lock)==(-1) ){
          tErrno = errno;
          rc = sqliteErrorFromPosixError(tErrno, SQLITE_IOERR_UNLOCK);
          if( IS_LOCK_ERROR(rc) ){
            pFile->lastErrno = tErrno;
          }
          goto end_unlock;
        }
................................................................................
  pNew = (unixFile *)sqlite3_malloc(sizeof(*pNew));
  if( pNew==NULL ){
    rc = SQLITE_NOMEM;
    goto end_create_proxy;
  }
  memset(pNew, 0, sizeof(unixFile));
  pNew->openFlags = openFlags;

  dummyVfs.pAppData = (void*)&autolockIoFinder;

  pUnused->fd = fd;
  pUnused->flags = openFlags;
  pNew->pUnused = pUnused;
  
  rc = fillInUnixFile(&dummyVfs, fd, dirfd, (sqlite3_file*)pNew, path, 0, 0, 0);
  if( rc==SQLITE_OK ){
    *ppFile = pNew;







|







 







>

>







1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
....
5743
5744
5745
5746
5747
5748
5749
5750
5751
5752
5753
5754
5755
5756
5757
5758
5759
      if( handleNFSUnlock ){
        off_t divSize = SHARED_SIZE - 1;
        
        lock.l_type = F_UNLCK;
        lock.l_whence = SEEK_SET;
        lock.l_start = SHARED_FIRST;
        lock.l_len = divSize;
        if( unixFileLock(pFile, &lock)==(-1) ){
          tErrno = errno;
          rc = sqliteErrorFromPosixError(tErrno, SQLITE_IOERR_UNLOCK);
          if( IS_LOCK_ERROR(rc) ){
            pFile->lastErrno = tErrno;
          }
          goto end_unlock;
        }
................................................................................
  pNew = (unixFile *)sqlite3_malloc(sizeof(*pNew));
  if( pNew==NULL ){
    rc = SQLITE_NOMEM;
    goto end_create_proxy;
  }
  memset(pNew, 0, sizeof(unixFile));
  pNew->openFlags = openFlags;
  memset(&dummyVfs, 0, sizeof(dummyVfs));
  dummyVfs.pAppData = (void*)&autolockIoFinder;
  dummyVfs.zName = "dummy";
  pUnused->fd = fd;
  pUnused->flags = openFlags;
  pNew->pUnused = pUnused;
  
  rc = fillInUnixFile(&dummyVfs, fd, dirfd, (sqlite3_file*)pNew, path, 0, 0, 0);
  if( rc==SQLITE_OK ){
    *ppFile = pNew;

Changes to src/test_hexio.c.

308
309
310
311
312
313
314

315



316

317
318
319
320
321
322
323
  z = sqlite3_malloc( n+3 );
  n = sqlite3TestHexToBin(zOrig, n, z);
  z[n] = 0;
  nOut = sqlite3Utf8To8(z);
  sqlite3TestBinToHex(z,nOut);
  Tcl_AppendResult(interp, (char*)z, 0);
  sqlite3_free(z);

#endif



  return TCL_OK;

}

static int getFts3Varint(const char *p, sqlite_int64 *v){
  const unsigned char *q = (const unsigned char *) p;
  sqlite_uint64 x = 0, y = 1;
  while( (*q & 0x80) == 0x80 ){
    x += y * (*q++ & 0x7f);







>
|
>
>
>
|
>







308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
  z = sqlite3_malloc( n+3 );
  n = sqlite3TestHexToBin(zOrig, n, z);
  z[n] = 0;
  nOut = sqlite3Utf8To8(z);
  sqlite3TestBinToHex(z,nOut);
  Tcl_AppendResult(interp, (char*)z, 0);
  sqlite3_free(z);
  return TCL_OK;
#else
  Tcl_AppendResult(interp, 
      "[utf8_to_utf8] unavailable - SQLITE_DEBUG not defined", 0
  );
  return TCL_ERROR;
#endif
}

static int getFts3Varint(const char *p, sqlite_int64 *v){
  const unsigned char *q = (const unsigned char *) p;
  sqlite_uint64 x = 0, y = 1;
  while( (*q & 0x80) == 0x80 ){
    x += y * (*q++ & 0x7f);

Changes to test/badutf2.test.

101
102
103
104
105
106
107

108
109
110

111
112
113
114
115
116
117
118
119
  do_test badutf2-4.1.$i {
    sqlite3_reset $S
    sqlite3_bind_text $S 1 $xstr $len
    sqlite3_step $S
    utf8_to_ustr2 [ sqlite3_column_text $S 0 ]
  } $ustr


  do_test badutf2-5.1.$i {
    utf8_to_utf8 $uval
  } $u2u


}

do_test badutf2-4.2 {
  sqlite3_finalize $S
} {SQLITE_OK}


finish_test







>



>









101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
  do_test badutf2-4.1.$i {
    sqlite3_reset $S
    sqlite3_bind_text $S 1 $xstr $len
    sqlite3_step $S
    utf8_to_ustr2 [ sqlite3_column_text $S 0 ]
  } $ustr

  ifcapable debug {
    do_test badutf2-5.1.$i {
      utf8_to_utf8 $uval
    } $u2u
  }

}

do_test badutf2-4.2 {
  sqlite3_finalize $S
} {SQLITE_OK}


finish_test

Changes to test/oserror.test.

42
43
44
45
46
47
48





49
50
51
52
53
54
55
56
57
58
59

60
61
62
63
64
65
66

#--------------------------------------------------------------------------
# Tests oserror-1.* test failures in the open() system call.
#

# Test a failure in open() due to too many files.
#





do_test 1.1.1 {
  set ::log [list]
  list [catch {
    for {set i 0} {$i < 2000} {incr i} { sqlite3 dbh_$i test.db -readonly 1 }
  } msg] $msg
} {1 {unable to open database file}}
do_test 1.1.2 {
  catch { for {set i 0} {$i < 2000} {incr i} { dbh_$i close } }
} {1}

do_re_test 1.1.3 { lindex $::log 0 } {^os_unix.c:\d+: \(\d+\) open\(.*test.db\) - }



# Test a failure in open() due to the path being a directory.
#
do_test 1.2.1 {
  file mkdir dir.db
  set ::log [list]







>
>
>
>
>









|
|
>







42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72

#--------------------------------------------------------------------------
# Tests oserror-1.* test failures in the open() system call.
#

# Test a failure in open() due to too many files. 
#
# The xOpen() method of the unix VFS calls getcwd() as well as open().
# Although this does not appear to be documented in the man page, on OSX
# a call to getcwd() may fail if there are no free file descriptors. So
# an error may be reported for either open() or getcwd() here.
#
do_test 1.1.1 {
  set ::log [list]
  list [catch {
    for {set i 0} {$i < 2000} {incr i} { sqlite3 dbh_$i test.db -readonly 1 }
  } msg] $msg
} {1 {unable to open database file}}
do_test 1.1.2 {
  catch { for {set i 0} {$i < 2000} {incr i} { dbh_$i close } }
} {1}
do_re_test 1.1.3 { 
  lindex $::log 0 
} {^os_unix.c:\d+: \(\d+\) (open|getcwd)\(.*test.db\) - }


# Test a failure in open() due to the path being a directory.
#
do_test 1.2.1 {
  file mkdir dir.db
  set ::log [list]

test/progress.test became a regular file.

whitespace changes only

tool/mkopts.tcl became a regular file.

whitespace changes only