716 Commits

Author SHA1 Message Date
drh
d46beb06aa In os_unix.c, put ALWAYS() on unreachable branches associated with pathname
normalization.

FossilOrigin-Name: b45a08e3c7edfa76b699d3e29f28daa5bd08039668ec57121e4e85edf36150f1
2020-11-23 17:36:06 +00:00
drh
6fc74a4454 The xFullPathname method of the unix VFS now normalizes the filenames by
omitting surplus "/", "/./" and "/../" strings.

FossilOrigin-Name: c38dec6f52c01614c1bee8356daf0fcd9f708d029116e9bff51e06719a730dde
2020-11-19 21:12:08 +00:00
drh
f56a4bfcd1 Improvements to the mechanism that attempts to report SQLITE_CORRUPT if
pread() says that the underlying filesystem is corrupt.

FossilOrigin-Name: b887c7504e7edeba758f3c1203c6cc56eef499fe05e7e6c6d82939bf7d78c57f
2020-11-18 21:50:05 +00:00
drh
5a07d10fd1 On unix, for certain error codes of read()/pread() return
SQLITE_IOERR_CORRUPTFS instead of SQLITE_IOERR_READ.  And then convert this
error into SQLITE_CORRUPT prior to returning back to the application.

FossilOrigin-Name: 9538ea8447e7b07c05197d6ff2208d3e97b45798736c85b63e8f0c7a3a98c1f3
2020-11-18 12:48:48 +00:00
drh
7f42dcd901 Enhance the unix VFS so that it removes extra "/", "/./" and "/../" from
the database filename.

FossilOrigin-Name: 7ba89d3e5c68d970ed26c2ec6e6e34bae535c2cc0b22a022d20ac9ff4527b8ab
2020-11-16 18:45:21 +00:00
drh
78043e891a Add ALWAYS() to conditionals associated with SHM locking that are always true.
FossilOrigin-Name: b599e89076d60afede7d2b3503b9338ca863d0c2d25799afe4080a6186386ea9
2020-11-06 16:48:55 +00:00
drh
ddcfe92105 Do not invoke usleep() for more than 999999 microseconds.
FossilOrigin-Name: 1f5ed852f25515bbc0a7aaf236fdef40fa7e31805eee1249277fde4e68f95130
2020-09-15 12:29:35 +00:00
dan
2b06b0769e Ensure that the busy-handler count is reset at the end of each sqlite3_file_control() and sqlite3_prepare() (and _v2() and _v3()).
FossilOrigin-Name: 5dd05940617fb05ee2faf212b15afc3a8e9695318eccb76761b37359fea681d1
2020-09-04 17:30:59 +00:00
dan
6acdee6765 Fix handling of an xShmLock(SHARED, UNLOCK) call when the caller does not hold any lock on the specified slot, but another connection in the same process holds an EXCLUSIVE.
FossilOrigin-Name: 3eb365027b885e1f61965efd53a3643b6ff441ae01e79038a091314516a50dd4
2020-08-28 20:01:06 +00:00
dan
8337da6678 Modify the unixShmLock() function to avoid iterating through the (possibly large) set of connections to the same database file.
FossilOrigin-Name: e0faddf0dfc3a40b6b94408296dd781dd0264ecc9f2129ce4405438433fb00e0
2020-08-28 19:27:15 +00:00
drh
14f38b3d0a Try to make SQLite easier to compiler for Mac Catalyst. See
[https://sqlite.org/forum/forumpost/803387a1c5|forum post 803387a1c5].

FossilOrigin-Name: e1595a20d71e61957944cc2b634578968cda8fba08a1f1e75edba20dc9c6080b
2020-08-19 23:51:54 +00:00
drh
0c52f5a2b0 Fix other potentiall pointer aliasing problems associated with subclassing
of the sqlite3_file object for various VFS implementations.

FossilOrigin-Name: 270ac1a0f232d75537be40abae559004e950b992cb2c7e94cd6de66e96ae17bd
2020-07-24 09:17:42 +00:00
drh
067b92ba00 Extend the refactoring into extensions. Clean up stray newlines.
FossilOrigin-Name: 7a876209a678a34c198b54ceef9e3c041f128a14dc73357f6a57cadadaa6cf7b
2020-06-19 15:24:12 +00:00
drh
ccb2113a62 Refactoring various names. No changes in the resulting machine code.
FossilOrigin-Name: 7bb08b1bfcf184e4b59c8c9028926a0052612ff6a6731914ccdb8dee07ea4a98
2020-06-19 11:34:57 +00:00
dan
d31fcd4751 Expand upon a comment in os_unix.c. No changes to code.
FossilOrigin-Name: 77933dc4dbe0e0af3b13a14293a8bd684edc5056f4ae9291c6f95d4433bf90ce
2020-05-29 11:07:20 +00:00
dan
7a623e1d25 Fix a problem preventing building without SQLITE_ENABLE_SETLK_TIMEOUT defined.
FossilOrigin-Name: 98eb54c6d83992886f17a00b6fc8998df230e3b5f45bafc6fae0d15a9ee5a4c6
2020-05-06 20:45:11 +00:00
dan
7bb8b8a4f7 Add error code SQLITE_BUSY_TIMEOUT, used internally by the OS layer to indicate that a call to xShmLock() has failed due to timeout of a blocking lock.
FossilOrigin-Name: f3ef9c7c2b4ba3de1057ad569f068b241d5f23e6629d8e0dacf85e57fd13b8aa
2020-05-06 20:27:18 +00:00
dan
d0e6d13301 Add tests for running recovery when opening a write transaction or performing a checkpoint with blocking locks enabled. Fix some failing assert() statements.
FossilOrigin-Name: d096ea3fe20f8af90f9e3f798fd0a69527b32ac8e208ade58b9d0af0e831f41b
2020-05-06 17:18:57 +00:00
dan
58021b237a Unless upgrading an existing read transaction, have ENABLE_SETLK_TIMEOUT builds attempt to use a blocking lock when opening a write transaction on a wal mode database.
FossilOrigin-Name: d6f819a9e6b35f3fd558bd93255a6a24ad690a0fa15a82b009ca9c641db983c6
2020-05-05 20:30:07 +00:00
drh
3b9f154bb7 Do not use O_NOFOLLOW when opening a directory just to call fsync() on
that directory.

FossilOrigin-Name: 2fc80ef16ce5878311ab88a0c64631813572ffbb71f75363b4619c9667e0926b
2020-04-20 17:35:32 +00:00
dan
97ccc1bd11 Modifications to the way blocking locks are used in SQLITE_ENABLE_SETLK_TIMEOUT builds so that multiple processes or threads may not deadlock when operating on a single database.
FossilOrigin-Name: c516027d5fd876b7d0bf566435667d554db29ded30ad6fc1165caa4a93d015a0
2020-03-27 17:23:17 +00:00
drh
0ba3621592 Omit O_NOFOLLOW from the open() call when opening /dev/null, since /dev/null
is a symlink on Solaris, we are told.

FossilOrigin-Name: 0c683c43a62fe25c6cb765e4a31556ec91a7c21af79349b3d7eeb13f73dd1cdc
2020-02-13 13:45:04 +00:00
drh
09bee5743d Follow-up to check-in [c8c6dd0e6582ec91] - change the xAccess() method to
return true if the file exists and it is anything other than a regular file,
or if it is a regular file with a non-zero file size.

FossilOrigin-Name: 8a39803ef8db4d8cb0d231e66299525fad4e61266ca29b3704aebb88df1c745b
2019-12-27 13:30:46 +00:00
drh
96e8eebf96 In the xAccess() method of the unix VFS, return true if the named object
is a directory, regardless of what stat() reports as the st_size for the
object.  Different filesystems report st_size differently for directories.
Problem reported on the mailing list by Stefan Brüns.

FossilOrigin-Name: c8c6dd0e6582ec9103d007b294c42bb1820be1fa7dab85d873b04e0b90571626
2019-12-26 00:56:50 +00:00
drh
c398c65bee Revise the SQLITE_OPEN_NOFOLLOW so that it actually uses O_NOFOLLOW in the
open() system call.  This backs out the SQLITE_ACCESS_SYMLINK value but adds
the new SQLITE_OK_SYMLINK return code from the xFullPathname method of 
sqlite3_vfs when that routine resolves symbolic links. O_NOFOLLOW is always
included in open() system calls for journal files.

FossilOrigin-Name: 6a64fb6a2da6c98f1e87b55ad5689967e1db4eae2e08345471d95e28cd567e0f
2019-11-22 00:42:01 +00:00
drh
0933aad72c Add support for SQLITE_OPEN_NOFOLLOW.
FossilOrigin-Name: cb79c828496a703f1410f61458ebc1e15a92a63412b36f51945b2b5a32ec6e88
2019-11-18 17:46:38 +00:00
drh
e4079e1fc5 Allow compile-time options -DHAVE_GETHOSTUUID=0 and -DHAVE_GETHOSTUUID=1.
FossilOrigin-Name: 3bcb9cc104e0265a600b03415ad955187fc6445ea8e46dc656412cba5bc1d621
2019-09-27 16:33:27 +00:00
drh
edf8a7bf57 In the previous check-in, the variable should be openMode, not openFlags.
FossilOrigin-Name: 77b0db22d6c7a031f332bfcf1c8fcd94e464de9f2396f0327ee761a30ebc8b60
2019-09-25 11:49:36 +00:00
drh
1116b1785c In the unix VFS layer, do not attempt to chown() the journal to be the same
as the database if running in 8+3 filename mode.  Also, update the comments
on the chown() attempt to be more precise.

FossilOrigin-Name: ab853724a7e01ca32167d294c3c80d6632e805bdf39b6d56db82226a00ad72dc
2019-09-25 10:36:31 +00:00
drh
55220a6c70 Improved reuse of file descriptors for which close() is delayed to prevent
clearly of posix advisory locks.

FossilOrigin-Name: 509c1ba26a4c12c63ecf04ddfa2f175eaf4dd9b96ab7be15faebd36deb0a0a31
2019-08-06 20:55:06 +00:00
dan
ec9b2a132b Call ioctl() with the correct signature on both Android and stock Linux.
FossilOrigin-Name: 68e12e063fe41bcd65cf8a120f838b9b1723ed803ea85240fe0f2145b78df2d7
2019-07-15 07:58:28 +00:00
drh
8616cff6c8 Remove unreachable "break" statements to silence harmless compiler warnings
from ICC.

FossilOrigin-Name: 0d7287e1bfdd5a392bf2fb17699e7cfd0b08bf61fab6cbf4b4bb347b3c4b4610
2019-07-13 16:15:23 +00:00
drh
aadf8327be Back out the change to support Fuchsia, since it turns out fuchsia does not
like dot-file locks.

FossilOrigin-Name: 1d801a3b2c48dc8a918d6da047bc877acf033d5f5c4e1d4b412ba7678ed6f8b3
2019-03-15 19:08:23 +00:00
drh
6a1bfc9a6d Changes to the unix VFS that allegedly enable it to build of Fuchsia.
We have no way of testing this.

FossilOrigin-Name: be21a6416d47ff7db995006a0422b745044d9b8bb5bad3c53342aa6e2e524771
2019-02-20 19:20:16 +00:00
drh
f7f2a82aa0 On the first connection to a WAL-mode database that was not cleanly shut down
and contains a left-over -shm file, truncate the -shm file to 3 bytes instead
of to 0 bytes. Avoiding a truncation to 0 means that system monitoring tools
can better detect if a process illegitimately tries to truncate a -shm file.
Such a rogue process might think it is being helpful by cleaning up old files,
but there is a race condition that can cause damage to the database.

FossilOrigin-Name: 90cf32cde072a305f30c75a71665d1f9e23e805c0a49f5306f015c056dd70f0c
2018-10-11 13:51:48 +00:00
drh
b6c4d59e89 In the unix VFS, fix the heap shm allocator (used for unix-excl)
so that it works even on systems where the page size is larger than 32KB.

FossilOrigin-Name: 7fbb083c5cf0948af3624b7538ffa086f77de27a3e84a7039ae7d6574f1a3a54
2018-10-11 02:39:11 +00:00
drh
9b7e8e10f2 Add an additional assert() verifying mutex invariants on the
unixShmSystemLock() routine in the unix VFS.

FossilOrigin-Name: cb1511065d5348c5b3015dc9d690fc5d519a14ffdfa7164bb552a4fa686ad142
2018-10-02 20:16:41 +00:00
drh
8820c8d3ee Additional field name changes and commit fixes associated with shared-memory
locking in the unix VFS, to improve maintainability.  No logic changes.

FossilOrigin-Name: 9280774a4bbc665d70f346d258768cbcca3e0e77791473aecfd7d0e87810ab31
2018-10-02 19:58:08 +00:00
drh
24efa5444d Fix comments and refactor some names associated with shared-memory locking
in the Unix VFS.  No logical changes.

FossilOrigin-Name: 3e9f1635271c92dce5324728b4ee1cc1a1856ec3c60b1b512a652c21e010e63e
2018-10-02 19:36:40 +00:00
dan
16f39b6e5d Fix a problem building on Android with SQLITE_ENABLE_BATCH_ATOMIC_WRITE set.
FossilOrigin-Name: e41e50fe7430cb79f67369fe81ac9938665bfc5db59c4faaf429ceb8ca03f584
2018-09-18 19:40:18 +00:00
dan
a86acc2132 Fix an assert() in os_unix.c that is not true when using RBU.
FossilOrigin-Name: 028ed8618af012b51104a06cc155b45d98bc4ff833d4431b9c38fd6851a74e82
2018-09-12 20:32:19 +00:00
drh
cb4e4b00b3 Fix a harmless compiler warning in os_unix.c.
FossilOrigin-Name: b9d1fb5d44e0a6ffc00ee987f178e448d7516e579beecdeeb387e69aef588921
2018-09-06 19:36:29 +00:00
drh
3fcef1a3f9 Fix a harmless unused-variable compiler warning that only came up in certain
compile-time configurations.

FossilOrigin-Name: 456842924bb33c0af8af29402f06e5f25b6791f698a0d12a080258b20b0cfb61
2018-08-16 16:24:24 +00:00
drh
ef52b36a6b Stop requiring the global VFS mutex to access the unixInodeInfo.pUnused field.
The unixInodeInfo mutex is sufficient.

FossilOrigin-Name: e3ea43dabf099dc2954c23d348638e7b2a8b9122d2994154bc649a2c09260c46
2018-08-13 22:50:34 +00:00
drh
095908e1c7 Take extra precautions to ensure access to unixInodeInfo.pUnused is protected
by all necessary mutexes.

FossilOrigin-Name: 8b1e0010b9e0b548a90087f4d25843d2b40f7e9551722ac587fa925d37b510c2
2018-08-13 20:46:18 +00:00
drh
3e2c842e46 Fix an incorrect comment on the unix-nolock VFS object. No functional
code changes.

FossilOrigin-Name: 90f7c193b42f0d8120a8e429bdea5e1cec5d3f45b901db8fc5a5c2ca3e69cba8
2018-08-13 11:32:07 +00:00
drh
6886d6dbc4 Return an SQLITE_NOMEM error if the locking mutex fails to allocate.
FossilOrigin-Name: 1c94834879be0601ac40ef3c4fb1b140f7737e89af7808f2f1db4ceb3daae19f
2018-07-23 22:55:10 +00:00
drh
da6dc2404a First attempt at reducing mutex contention in the unix VFS by providing
a separate mutex for each unixInodeInfo object.

FossilOrigin-Name: f69afaf00a659cd768a863c5f4a1d527f01187e037240da0ada527cb52c5afe8
2018-07-23 21:10:37 +00:00
drh
789df14b11 Proposed fix for the use of posix_fallocate() so that it handles EINVAL
returns correctly.

FossilOrigin-Name: ab3a5539db82814cafb832cdaebd1e14566139306453ef9cdba6b244a994fe0b
2018-06-02 14:37:39 +00:00
drh
fd72563d0a Avoid a race condition that might cause a busy_timeout to last longer than
it should.

FossilOrigin-Name: b81960561b47a1b49646f2f8870dd0684dc4ca7c0b9e11076fd713de66b75972
2018-03-26 20:43:05 +00:00