/ Changes On Branch tkt-5eaa61ea18
Login

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

Changes In Branch tkt-5eaa61ea18 Excluding Merge-Ins

This is equivalent to a diff from 5a3b07f0f5 to 597333f102

2012-11-13
11:16
Strive to use posix_fallocate() rather than ftruncate() when posix_fallocate() is available. Ticket [5eaa61ea18]. (check-in: 29980b08ec user: drh tags: trunk)
11:08
Use preprocessor macros to automatically detect whether or not posix_allocate() is available. (It is generally available on Linux but not on Mac.) Ticket [5eaa61ea1881040b17449ca043b6f8fd9ca55dc3] (Closed-Leaf check-in: 597333f102 user: drh tags: tkt-5eaa61ea18)
10:54
When available, use posix_fallocate() rather than ftruncate() to allocate space for mmap()ed -shm files, since posix_fallocate() gives an error if no disk space is available whereas ftruncate() is silent and leaves the system vulnerable to a SIGBUS upon first write to the mmap()ed region. Ticket [5eaa61ea1881040b17449ca043b6f8fd9ca55dc3] (check-in: 356259617c user: drh tags: tkt-5eaa61ea18)
2012-11-10
01:27
Merge the latest changes from trunk: chiefly the outer/inner loop query optimizer scoring enhancement and the INSTR() function. (check-in: 2993ca2020 user: drh tags: sessions)
2012-11-09
21:40
Only log unlink() errors if the error is something other than SQLITE_IOERR_DELETE_NOENT. The error is still reported up the stack, it is simply not added to the sqlite3_log(). (check-in: 5a3b07f0f5 user: drh tags: trunk)
20:17
Change os_unix.c to propagate ENOENT errors back to sqlite as SQLITE_IOERR_DELETE_NOENT. Have SQLite ignore these where they are benign and propagate them back to the caller where they may indicate a file-system malfunction of some description. (check-in: bed9c172ce user: dan tags: trunk)

Changes to src/os_unix.c.

42
43
44
45
46
47
48







49
50
51
52
53
54
55
**   *  Locking primitives for the proxy uber-locking-method. (MacOSX only)
**   *  Definitions of sqlite3_vfs objects for all locking methods
**      plus implementations of sqlite3_os_init() and sqlite3_os_end().
*/
#include "sqliteInt.h"
#if SQLITE_OS_UNIX              /* This file is used on unix only */








/*
** There are various methods for file locking used for concurrency
** control:
**
**   1. POSIX locking (the default),
**   2. No locking,
**   3. Dot-file locking,







>
>
>
>
>
>
>







42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
**   *  Locking primitives for the proxy uber-locking-method. (MacOSX only)
**   *  Definitions of sqlite3_vfs objects for all locking methods
**      plus implementations of sqlite3_os_init() and sqlite3_os_end().
*/
#include "sqliteInt.h"
#if SQLITE_OS_UNIX              /* This file is used on unix only */

/* Use posix_fallocate() if it is available
*/
#if !defined(HAVE_POSIX_FALLOCATE) \
      && (_XOPEN_SOURCE >= 600 || _POSIX_C_SOURCE >= 200112L)
# define HAVE_POSIX_FALLOCATE 1
#endif

/*
** There are various methods for file locking used for concurrency
** control:
**
**   1. POSIX locking (the default),
**   2. No locking,
**   3. Dot-file locking,
4164
4165
4166
4167
4168
4169
4170







4171
4172
4173
4174
4175

4176
4177
4178
4179
4180
4181
4182
        /* The requested memory region does not exist. If bExtend is set to
        ** false, exit early. *pp will be set to NULL and SQLITE_OK returned.
        **
        ** Alternatively, if bExtend is true, use ftruncate() to allocate
        ** the requested memory region.
        */
        if( !bExtend ) goto shmpage_out;







        if( robust_ftruncate(pShmNode->h, nByte) ){
          rc = unixLogError(SQLITE_IOERR_SHMSIZE, "ftruncate",
                            pShmNode->zFilename);
          goto shmpage_out;
        }

      }
    }

    /* Map the requested memory region into this processes address space. */
    apNew = (char **)sqlite3_realloc(
        pShmNode->apRegion, (iRegion+1)*sizeof(char *)
    );







>
>
>
>
>
>
>





>







4171
4172
4173
4174
4175
4176
4177
4178
4179
4180
4181
4182
4183
4184
4185
4186
4187
4188
4189
4190
4191
4192
4193
4194
4195
4196
4197
        /* The requested memory region does not exist. If bExtend is set to
        ** false, exit early. *pp will be set to NULL and SQLITE_OK returned.
        **
        ** Alternatively, if bExtend is true, use ftruncate() to allocate
        ** the requested memory region.
        */
        if( !bExtend ) goto shmpage_out;
#if defined(HAVE_POSIX_FALLOCATE) && HAVE_POSIX_FALLOCATE
        if( osFallocate(pShmNode->h, sStat.st_size, nByte)!=0 ){
          rc = unixLogError(SQLITE_IOERR_SHMSIZE, "fallocate",
                            pShmNode->zFilename);
          goto shmpage_out;
        }
#else
        if( robust_ftruncate(pShmNode->h, nByte) ){
          rc = unixLogError(SQLITE_IOERR_SHMSIZE, "ftruncate",
                            pShmNode->zFilename);
          goto shmpage_out;
        }
#endif
      }
    }

    /* Map the requested memory region into this processes address space. */
    apNew = (char **)sqlite3_realloc(
        pShmNode->apRegion, (iRegion+1)*sizeof(char *)
    );

Changes to test/wal9.test.

58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
  COMMIT;
} {}

# Check file sizes are as expected. The real requirement here is that 
# the *shm file is now more than one chunk (>32KiB).
do_test 1.3 { file size test.db     } {1024}
do_test 1.4 { file size test.db-wal } {15421352}
do_test 1.5 { file size test.db-shm } {131072}

do_execsql_test 1.6 { PRAGMA wal_checkpoint } {0 14715 14715}

# At this point connection [db2] has mapped the first 32KB of the *shm file
# only. Because the entire WAL file has been checkpointed, it is not 
# necessary to map any more of the *-shm file to read or write the database
# (since all data will be read directly from the db file). 







|







58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
  COMMIT;
} {}

# Check file sizes are as expected. The real requirement here is that 
# the *shm file is now more than one chunk (>32KiB).
do_test 1.3 { file size test.db     } {1024}
do_test 1.4 { file size test.db-wal } {15421352}
do_test 1.5 { expr {[file size test.db-shm]>32768} } {1}

do_execsql_test 1.6 { PRAGMA wal_checkpoint } {0 14715 14715}

# At this point connection [db2] has mapped the first 32KB of the *shm file
# only. Because the entire WAL file has been checkpointed, it is not 
# necessary to map any more of the *-shm file to read or write the database
# (since all data will be read directly from the db file). 
83
84
85
86
87
88
89
90
      INSERT INTO t VALUES('hello');
    ROLLBACK;
  } db2
} {}
db2 close

finish_test








<
83
84
85
86
87
88
89

      INSERT INTO t VALUES('hello');
    ROLLBACK;
  } db2
} {}
db2 close

finish_test