Commit Graph

501 Commits

Author SHA1 Message Date
drh
0d0614bdc6 Memory-mapped I/O is now on by default. The "PRAGMA mmap_limit(N)" can be
used to issue a hint to the VFS to limit mmap space to N bytes.  The VFS
is free to ignore that hint if desired.  However, if "PRAGMA mmap_limit(0)"
is used, xFetch is never called.

FossilOrigin-Name: 1b37c4effdd03aa2ea938a71b4f22ed27391689b
2013-03-25 23:09:28 +00:00
drh
d1ab8065c1 Add munmap and mremap to the set of os interfaces that can be overloaded
in os_unix.c.

FossilOrigin-Name: 8776047bd776bbf266eb9c3b56683badb84ae73e
2013-03-25 20:50:25 +00:00
dan
b7e3a326fe Use mremap() on Linux.
FossilOrigin-Name: 431aecc8600c29c203546e48d256510510238887
2013-03-25 20:30:13 +00:00
drh
dee6554811 Merge all recent trunk changes into the experimental-mmap branch.
FossilOrigin-Name: a607d63f0b6a3d3785e9385187d3e6b92e14fc70
2013-03-25 19:57:26 +00:00
dan
893c0ffc29 Add a test that simulates an error in mmap().
FossilOrigin-Name: 6ec7367d8e98425f00eeb8215ca8964313c1d0b7
2013-03-25 19:05:07 +00:00
dan
df737fe6f5 Change the signature of the xUnfetch method to "int (*xUnfetch)(sqlite3_file*, sqlite3_int64 iOfst, void *p)".
FossilOrigin-Name: 115b830509e8f0aa9d5965c1e9cd4f2ed9d01938
2013-03-25 17:00:24 +00:00
dan
aef49d7141 Remove unnecessary code to round the size of a memory mapping to 4KB from os_unix.c. Rename SQLITE_IOERR_MREMAP to SQLITE_IOERR_MMAP. Fix other small issues in os_unix.c.
FossilOrigin-Name: dce35c01a5fe66d2970075b1e3f0376026485e4c
2013-03-25 16:28:54 +00:00
dan
a1afc7425a Fix a case in the pager where an xFetch() reference was being leaked following an OOM error.
FossilOrigin-Name: 5885ba6ce768658ec25b60747430d147b315b55c
2013-03-25 13:50:49 +00:00
dan
f23da96636 Replace the sqlite3_io_methods.xMremap interface with sqlite3_io_methods.xFetch and xUnfetch.
FossilOrigin-Name: 1431be95579160fb70408d43e17fc23c7b69ab4a
2013-03-23 21:00:41 +00:00
dan
c00033125d Add a fix for the assert() statements added by the previous commit.
FossilOrigin-Name: 19345416ed5e1ab5b0b35993b0b9069c2fb1683b
2013-03-22 17:46:11 +00:00
dan
6101d50471 Add assert statements to os_unix.c to ensure that any mapped region of the database file is not being read or written using the xRead() or xWrite() methods.
FossilOrigin-Name: 765615f9fba7c1765eb741cb98a09a28b464ee55
2013-03-22 08:58:38 +00:00
mistachkin
48864df97d Many spelling fixes in comments. No changes to code.
FossilOrigin-Name: 6f6e2d50941e444ebc83604daddcc034137a05b7
2013-03-21 21:20:32 +00:00
dan
c71b45e619 Do not use the Linux mremap() call. Use the same strategy for xMremap() as on OSX instead.
FossilOrigin-Name: 5ed8ad780c991d2ca44003ee84350fb5e95ad58e
2013-03-21 14:47:47 +00:00
dan
d306e1a3a1 Optimize the xMremap method in os_unix.c some.
FossilOrigin-Name: 9529ed88a71fee02fae72dc86f0669bd6856ff92
2013-03-20 18:25:49 +00:00
dan
eb97b29345 When possible, use memory mapping when appending new pages to a database file.
FossilOrigin-Name: 14135da3cdbafd699563a29608f32347cda28338
2013-03-20 14:26:59 +00:00
dan
5d8a137218 Add the sqlite3_io_methods.xMremap() method to the VFS interface. Also "PRAGMA mmap_size".
FossilOrigin-Name: 6183f1bd86ceed76d22d9762f3d7eb33262c62d1
2013-03-19 19:28:06 +00:00
dan
b2d3de3bf4 Use mmap() to read from the database file in rollback mode. This branch is unix only for now.
FossilOrigin-Name: 6f21d9cbf5d457e63a7282015a89ae785526cf6d
2013-03-14 18:34:37 +00:00
drh
cfc176973e Fix an operator precedence problem on the [1d8086902e] check-in.
FossilOrigin-Name: 4f5f3aebe81c3cbe539db3e33ec38fa3de47e90b
2013-03-06 01:41:53 +00:00
dan
b83c21e600 Do not attempt to set the permissions on an existing journal or wal file. Do this only immediately after creating a new file (or opening one zero bytes in size).
FossilOrigin-Name: 1d8086902ee96347491bce5ec04dc92ccd42efa1
2013-03-05 15:27:34 +00:00
drh
503a686e09 Always use strncmp() rather than memcmp() when comparing strings where one
or other string might be less than the length parameter, since optimized
versions of memcmp() might read past the first difference and in so doing
generate an access violation.

FossilOrigin-Name: d73435587ba7459e2e2c32980d0e17abdeceb4bc
2013-03-01 01:07:17 +00:00
drh
e1186ab260 Do not use umask() since it change the umask for the entire process, not just
the thread using SQLite.  Make whatever permission changes are needed using
fchmod() after the file is created, instead.

FossilOrigin-Name: 6c4c2b7dbadedac384d380efd54f12f6ccbf4ca9
2013-01-04 20:45:13 +00:00
drh
696b33e622 Add the SQLITE_FCNTL_TEMPFILENAME file control that asks the underlying VFS
to return a new temporary filename.  Per request from NSS team at Mozilla.

FossilOrigin-Name: 1a63b1d5fa5d79f96eddbda6d94bc10248863710
2012-12-06 19:01:42 +00:00
drh
6033e15aa2 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]

FossilOrigin-Name: 597333f1024092b94bcd8772541e19a0f707bd40
2012-11-13 11:08:49 +00:00
drh
0fbb50ee15 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]

FossilOrigin-Name: 356259617cfad04492a02912fdf781f54a2b4494
2012-11-13 10:54:12 +00:00
drh
b43081675d 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().

FossilOrigin-Name: 5a3b07f0f5dfae7eea870303f52f37d6a17f1da2
2012-11-09 21:40:02 +00:00
dan
9fc5b4a539 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.
FossilOrigin-Name: bed9c172ce624ab7b5b9de9ad42444891717ad9a
2012-11-09 20:17:26 +00:00
drh
537dddf0cd Add QNX-specific performance tweaks to the unix VFS. (Cherry-pick merge of
[b02849e7bde458].)

FossilOrigin-Name: 63a7dd75e61afb3d05a1434f66ad6a5f08352aad
2012-10-26 13:46:24 +00:00
drh
5a05be1b68 Attempt to suppress warnings generated by Coverity.
FossilOrigin-Name: 7b1a6e6cb5099076bf19db142b17c99044a869cd
2012-10-09 18:51:44 +00:00
drh
c1fd2cfed2 Make sure the size parameter to read and write VFS methods in the unix VFS
do not become too big or go negative.  This was not actually possible in the
current code.  The checks are added to make sure some future bug does not
make it possible.

FossilOrigin-Name: daebe3bd2d9bd7b6f876a8110cf5045eb3fee078
2012-10-01 12:16:26 +00:00
mistachkin
d5578433ff Fix all known instances of 'repeated the' style typos in comments. No changes to code.
FossilOrigin-Name: 9b19b847533f944f289d93dcdba29c0d67bf251c
2012-08-25 10:01:29 +00:00
drh
f2f105d40e Remove tab characters from source code files. Replace them with spaces.
FossilOrigin-Name: 7edd10a960d5ff121e470b0549b0aa9fb7760022
2012-08-20 15:53:54 +00:00
drh
ed46682719 Avoid calling fchown() if the process is not running as root.
FossilOrigin-Name: 70c419a434be77b042a23174483d6a411899eb5d
2012-05-31 13:10:49 +00:00
drh
d3d8c04fd1 Changes some NDEBUG macros to SQLITE_DEBUG in os_unix.c. The is a notational
change only and really should not effect the code.

FossilOrigin-Name: 8e3025709e4954803919c84f3a810c7c63c60601
2012-05-29 17:02:40 +00:00
drh
5adc60bab0 In the unix VFS, always set every open file to close-on-exec using either
O_CLOEXEC at open (preferred) or FD_CLOEXEC in an ioctl after opening.  Before
this changes, many files were done this way, but not all.

FossilOrigin-Name: 9efbeb11ae0d480a13ff1353820c12f3a8bff452
2012-04-14 13:25:11 +00:00
drh
b8af4b7919 Ignore the value of SQLITE_FCNTL_CHUNK_SIZE if it is negative.
FossilOrigin-Name: 1b08fef9451f4d59148548faed115d1a5d0bcd98
2012-04-05 20:04:39 +00:00
drh
ef595984ec Fix a harmless compiler warning introduced by the previous check-in.
FossilOrigin-Name: a8a042a751557d06bf04455ed7629cb29adcd87f
2012-02-13 20:28:15 +00:00
drh
8c815d14f8 On unix, ignore the umask when creating journal files. That way, journal files
will have exactly the same permissions as the original database and any
process that has permission to write to the database can also recover
hot journals.

FossilOrigin-Name: 84b324606adc8437338c086404eb157f30f04130
2012-02-13 20:16:37 +00:00
dan
d3eaebd414 Fix a typo in the type of the fchown() function in os_unix.c.
FossilOrigin-Name: bfbfe05b81919ecc3d6e7be4c24994f795f16582
2012-02-13 08:50:23 +00:00
drh
23c4b97329 Make fchown() an overrideable system call in os_unix.c.
FossilOrigin-Name: 98efac9630ca96ba0497c8e206dc5022612ff381
2012-02-11 23:55:15 +00:00
drh
3ee3484c4a Silence GCC compiler warnings about unused return value from fchown().
FossilOrigin-Name: b022547389a40930cf0d2a75f5eb293acc9fbfe0
2012-02-11 21:21:17 +00:00
drh
ac7c3ac150 When creating journal files (including -wal and -shm files) try to set the
ownership to be the same as the original database.  This will prevent root
from locking out the original owner of the file.

FossilOrigin-Name: 1254dffe4071656a783cd000b1dd40c975ac18cb
2012-02-11 19:23:48 +00:00
drh
c96d1e79a8 Remove a redundant test from the shared-memory logic in os_unix.c.
FossilOrigin-Name: 31142ca795005bf664f34000591e6572c72652f2
2012-02-11 18:51:34 +00:00
drh
c18b40462b Fix an important bug in the handling of EINTR in unixRead(). Never came
up on x86 but crashes on sparc.

FossilOrigin-Name: 1a16db0bca717a2582a48332d81854ca90d6d49b
2012-02-10 03:10:27 +00:00
drh
c02a43afae Only require double-zero terminators on database filenames, not any every
files supplied to the xOpen method.  This backs out [2544f233f1].  Also
refactor the fillInUnixFile() routine in os_unix.c to reduce the number
of parameters.

FossilOrigin-Name: cb774b26e13745cfad0d76a71e47466d703e0007
2012-01-10 23:18:38 +00:00
drh
9cb5a0d989 Make sure the name of the shared memory file has two zero-terminators in the
UNIX VFS, so that sqlite3_uri_parameter() will work correctly on that name.

FossilOrigin-Name: 3d088ba5e36c0b6bccc86986f8fa9a22b340c297
2012-01-05 21:19:54 +00:00
drh
e349519f1e Change the unix VFS so that it ignores all but the least-significant bit
of the syncDir flag to xDelete.  Add an assert to prove that the core only
ever uses that one bit.

FossilOrigin-Name: e75fd3b27423272b988921ac0e272f9600818b8c
2012-01-05 16:07:30 +00:00
drh
bce51350d6 Remove the SQLITE_FCNTL_SYNC_OMITTED cases from the unix and windows VFSes
as they are no longer needed because of check-in [fd3822f1f2].

FossilOrigin-Name: 7cf568a101cda20ab6005bd250154b7f6960193a
2012-01-05 11:43:10 +00:00
drh
52bcde0e2d Make sure filenames passed into sqlite3OsOpen() always have the extra
zero-terminators needed by sqlite3_uri_parameter().

FossilOrigin-Name: d73e93cfdc9441ade77b796dcdcf6eeb753cb398
2012-01-03 14:50:45 +00:00
drh
8942d4125e Remove the code that attempts to find the sector size from the OS and
hardcode the xSectorSize methods of the unix and windows VFSes to return
SQLITE_DEFAULT_SECTOR_SIZE, which is now set to 4096 unless overridden.

FossilOrigin-Name: 03d8362cd2cadab8e1cc5b18a3194152f2bd0a84
2012-01-02 18:20:14 +00:00
drh
cb15f35f3b Change the name ZERO_DAMAGE to the more descriptive POWERSAFE_OVERWRITE.
The query parameter used to control this device characteristic is now "psow".

FossilOrigin-Name: 6191c5e45175f5c6040e891843b0725a929d6dd7
2011-12-23 01:04:17 +00:00