1
0
mirror of https://github.com/sqlite/sqlite.git synced 2025-08-04 04:42:17 +03:00
Commit Graph

403 Commits

Author SHA1 Message Date
drh
b0c3118cad Clarify and reduce redundancy in an assert() in walChecksumBytes().
FossilOrigin-Name: 3c53abf5e6df446d569040042363265737aa10fc8aaa20b31c587100c557c5e7
2025-03-24 23:08:40 +00:00
drh
cebf06c798 Make use of the flexible-array feature of C99, when available, to try to
pacify -fsanitize=strict-bounds.  This check-in fixes the core. There is
more yet to do in FTS3, RTREE, and in FTS5.

FossilOrigin-Name: 6fd6b32d06bd6a705e5140cd613af823b8183a6f6a9ceeeedfcf5e8b50821d68
2025-03-14 18:10:02 +00:00
dan
58bc525e32 Reinstate the assert() removed by [0f6223b8]. Avoid holding a wal-mode write lock after the transaction has been rolled back if an IO error occurs while restarting the wal file.
FossilOrigin-Name: 277e150d6ab75de2407f6761aa2359df80a4e1dbce30788df06621dee05b2ef1
2025-02-25 15:27:55 +00:00
dan
a4cf066d64 Remove an assert() added by [e88212b1] that is sometimes false.
FossilOrigin-Name: 0f6223b8f6c044db687f78e19f6373d0dda9155445c511a297efa05bac3b16e5
2025-02-25 11:29:04 +00:00
dan
b081a391ce Merge latest changes from trunk into this branch.
FossilOrigin-Name: 55324d1c862c42b95251a398c40930d9fa94debb1aec7d3d0ae734d6b17b4a59
2025-02-24 10:52:34 +00:00
drh
ef86b942b9 Code changes that make it easier to prove that no 32-bit integer overflows
happen during memory allocation.  No problems fixed; this change is just
to make future maintenance easier.

FossilOrigin-Name: 215650a5a1d55bdbca9c92524804a1a54456a17f42a17e53747b21a6507506f5
2025-02-17 17:33:14 +00:00
dan
df54ecb1bf Fix a problem causing the write-lock to be held when it should not be in some circumstances following a SEH exception.
FossilOrigin-Name: 7eb5accb7cf937fc967dcd86da0af813fb18a2697348bd231fbefd3c09b930ab
2025-01-30 17:04:28 +00:00
dan
43aad25b1b Add the sqlite3_setlk_timeout() API. For setting the timeout used by SQLITE_ENABLE_SETLK_TIMEOUT blocking locks without also setting the regular retry-based busy-timeout.
FossilOrigin-Name: 4a7eb492797abb47b18b7dfc557aeae43a0dea5b861efc203398d5059b10d131
2025-01-27 11:50:03 +00:00
dan
2539fb2bc5 Fix a race condition causing SQLite to use a busy-handler for an operation that should not.
FossilOrigin-Name: 6ab9ed8eef77781898375038ab05fc6e5f46b745e4906691393b8b1d90570eb6
2025-01-24 15:49:47 +00:00
drh
32dd04b41e Code formatting changes to make trunk more like wal2.
FossilOrigin-Name: 8f725472b0fe62359a4cd3237b43d7b834e042d8ce425abde06e3ed6c62dbafa
2024-12-16 18:04:39 +00:00
drh
276172e4a3 Remove unnecessary end-of-line whitespace.
FossilOrigin-Name: ae580443d210811c12209866112fc8b0b83281e24945504b748a17d93ad84062
2024-12-16 12:08:47 +00:00
624cb96f54 An assortment of comment typo fixes discovered by aspell. Add several new words to tool/custom.txt. No code changes.
FossilOrigin-Name: 59b76a99e4a28f4cc8c4f9f39ff6e039c4d29cb7b44183f1902b5792638656d2
2024-10-19 12:39:06 +00:00
dan
d0720eee5e When possible, avoid taking wal file read-lock 0 in sqlite3_snapshot_get().
FossilOrigin-Name: 34b6ac3d76dbc6819778ec2a0f81cbcdcc0cd1a6303381d97f1c479e4ecdd132
2024-09-26 18:02:17 +00:00
drh
5600adf1b1 Move the vfstrace extension out of src/ over into ext/misc/ where it belongs.
Make it part of the standard build for the CLI.  Bring some of the vfstrace
output up-to-date.

FossilOrigin-Name: 055b97de8d2397987d72dbab1cde78ece2d1c066e95042b4ed6b7b36b2cf9006
2024-09-09 14:50:23 +00:00
drh
5fdabcf9ff Put an SQLITE_ENABLE_SETLK_TIMEOUT branch inside the appropriate ifdef with
an assert on the else since the condition is always false if SETLK_TIMEOUT
is not available.

FossilOrigin-Name: d81e7a036ac5d70b6a6ee6ab7d81e041c1f5fc04b70bcee47e203d521caf7e93
2024-01-09 23:15:46 +00:00
dan
4e50f7763b Ensure that SQLITE_PROTOCOL is not returned too early when a SQLITE_ENABLE_SETLK_TIMEOUT build fails to open a transaction on a wal mode database in cases where blocking locks are not being used.
FossilOrigin-Name: b934a33671d8a0190082ad7e5e68c78fe0c558d102404eafc1de26e4e7d65b92
2024-01-06 19:16:54 +00:00
drh
f5740f72ec Adjust the sqlite3PagerDirectReadOk() routine (part of the
SQLITE_DIRECT_OVERFLOW_READ optimization) to use less code and to be
more easily testable.

FossilOrigin-Name: eed670ea2a9424f7df4eeb01c152fc38f7190a5e39aa891651b28dc91fcdc019
2024-01-02 21:37:51 +00:00
dan
940b23bc3a In SQLITE_ENABLE_SETLK_TIMEOUT builds, use blocking locks in place of sleep() calls when opening a read-transaction.
FossilOrigin-Name: 4c055b7a6e4533e1e571773456226ca7038ce372df3eedbbbcd9a81e8652a6cf
2023-11-28 17:12:42 +00:00
dan
b8950e0f45 Handle an SQLITE_BUSY_TIMEOUT error if one occurs while attempting a shared lock on a read-lock slot.
FossilOrigin-Name: 5fbf3906d272df3eb981f67455eb35f649ad2774cba9fc3f077b28d9bef3f0cb
2023-11-28 15:29:04 +00:00
dan
bae2d0f2eb Have SQLITE_ENABLE_SETLK_TIMEOUT builds block when locking a read-lock slot.
FossilOrigin-Name: f797baf47cf7859cfd8ce248f4f3087af4551a7040af990333426e5a7c269504
2023-11-27 20:37:03 +00:00
dan
e52854a9e6 In SQLITE_ENABLE_SETLK_TIMEOUT builds, use blocking locks in place of sleep() when opening a read-transaction.
FossilOrigin-Name: a51ef39998e25e86bd0600e71d15011b12e05f4319608018293bdaecb09e8c97
2023-11-27 19:22:50 +00:00
dan
91c8e65dd4 Changes so that if SQLITE_ENABLE_SETLK_TIMEOUT is defined as 2 instead of 1, all blocking locks are taken for a single millisecond and the default busy-handler invoked as normal.
FossilOrigin-Name: 79e24ec3dd40373bbb93792829b18d9ef40daf19d4606174e36c8e19e61a7529
2023-11-15 19:19:04 +00:00
dan
0ad5301378 Avoid blocking as part of passive checkpoint operations, even if SQLITE_ENABLE_SETLK_TIMEOUT is defined.
FossilOrigin-Name: e5ecc404cae1ce8b639d0263fa07571c066f11bfc62f5ba331ad7ae138e78572
2023-11-08 15:49:57 +00:00
drh
36a9f5c24c Fix a possible UAF in SEH if an exception occurs at an inopportune moment
during WAL processing.

FossilOrigin-Name: 91b91037e348fa10cf6a9d8a0ffbfdebb4a40e0e336b65b112ed1c828e75cda7
2023-08-17 14:19:44 +00:00
dan
9541fbc283 Fix a problem in sqlite3_snapshot_recover() introduced by the [8a6b0c24937e855b] merge.
FossilOrigin-Name: c2577eb0a4a627c65d675f1446514843486092be9cb271b682793a0107e496cd
2023-08-14 18:21:56 +00:00
dan
5e22dfb6a5 Add a comment describing the contents of the ExceptionInformation[] array for win32 EXCEPTION_IN_PAGE_ERROR exceptions. No changes to code.
FossilOrigin-Name: 8e20354242d5f34a90b6c00d9034535ef6f6086ee4971230c7fd69985e2777d2
2023-07-26 18:34:34 +00:00
drh
5202b7ca75 Update the latest trunk enhancements into the wal-shm-exceptions branch.
FossilOrigin-Name: 3187ee3f69fc28a259ba0e951ac10a65c07ef2c3866acbefaf9544333a930cc6
2023-07-24 12:59:53 +00:00
drh
8a1104940d Reduce divergence between branches: trunk and wal-shm-exceptions.
FossilOrigin-Name: d38ed6b1fc6b572997d520c36f256c11404fb1bd5f28acab07466bfc96554a8f
2023-07-11 19:54:17 +00:00
drh
66422b57f9 Get fault injection for testing working correctly. Other code clean-up.
FossilOrigin-Name: ff492277ed00c1f637a5b4ccd6d8193ea22f6781f90073861588a2b7d5c045b7
2023-07-11 15:52:52 +00:00
drh
5d3cc0c09b Fix a warning. Unclear yet if the code is correct this way or not.
FossilOrigin-Name: 2df4fd76ef48bb63389df8d783059af6b8f2cbb2c11d07953b408e71f50b625b
2023-07-10 18:16:49 +00:00
drh
cc9380f68d Merge the latest trunk enhancements into the wal-shm-exceptions branch.
FossilOrigin-Name: f655d08d019bab0c578886e91ca24fd956d1b3dea9b9c9104812b3cf62e5e556
2023-07-10 18:05:23 +00:00
drh
ff96718b52 Merge all recent trunk enhancements into the wal-shm-exceptions branch.
FossilOrigin-Name: e59cea2d851be68559e7d01a01cb05684c44d151d022ea9790ce99671016ab00
2023-07-06 17:55:33 +00:00
55be21647e Fix straggler misspellings and tidy the custom dictionary. Also include pickups from [forum:/info/c61fb09afd|forum post c61fb09afd].
FossilOrigin-Name: 8c291d99946eb32b20b743921202f9c7cfb716268ff526817b27adbb7942e40b
2023-06-07 17:03:22 +00:00
bc91738e66 Add a C-source spell-checking facility. make misspell (on Nix)
FossilOrigin-Name: 26c1bb4bd9e9f56613c3aa87407a7f562fd4ebde5bfd6dece02078001d9a45f8
2023-06-07 08:40:31 +00:00
drh
dda2833a4e Add a comment to the [0512f82a2cde7447] change to link it to its TH3 test case.
FossilOrigin-Name: 1281d4d9d799ef83e6eb51d656ede82b4503d39adf169deb936b30ebfddd88b1
2023-05-03 13:33:37 +00:00
drh
ce2aa8bebe If the page size is wrong on the page1 content inside a WAL file, then
running VACUUM could trigger an assert().  This check-in changes that assert()
into a branch that returns SQLITE_CORRUPT.
[forum:/info/4ef9b37d74d2d2e8|Forum post 4ef9b37d74d2d2e8]

FossilOrigin-Name: 0512f82a2cde7447cb348d9fd620f39f2f0e359141903cde20f7ba30b5d34af3
2023-05-03 06:48:08 +00:00
drh
3f4a319934 Unwrap the loop in the WAL hash function.
FossilOrigin-Name: eb94ae13206762a42ddad12e0d1461df83e9759e44a369f188cd3aad82f211c4
2023-04-12 20:23:03 +00:00
drh
fc7f8f81da Back out the optimization at [1a8c2e54375ee2cf7] because there are some
cases where it does not work.

FossilOrigin-Name: fe39c8d5fd813308fb27a05ce257ff003d3c09c0372f500e8def5a528a2558b7
2022-07-11 18:11:51 +00:00
drh
3325a5c497 Size reduction and performance optimization in sqlite3WalFindFrame().
FossilOrigin-Name: 1a8c2e54375ee2cf73773b798fed0ae07b42f5e068fddc513c093de5c1f46615
2022-07-04 15:14:25 +00:00
drh
f208abdd99 A better and more robust fix for the problem of reading a read-only WAL
mode database with existing -wal and -shm files, replacing [f426874e005e3c23].

FossilOrigin-Name: 71bfd0b57ab197405606b8096b8521d784ff174c4eecf1d9804d38342c03cc80
2022-01-20 14:40:34 +00:00
drh
d6b44ec32a Fix the ability to read read-only WAL-mode database when -shm is present,
([00ec95fcd02bb415|check-in 00ec95fcd02bb415]) so that it works
for the case of 64K page size.

FossilOrigin-Name: f426874e005e3c23e8a00083b7c201408e072bca413e52bfc436da6483afb0cd
2022-01-20 02:04:53 +00:00
drh
e574a9233c Fixes to internal comments. No changes to code or documentation.
FossilOrigin-Name: 1489b196ce82cddf7360aff6c89219ca25e666187f0f5ff6419ba3b504cdef8d
2021-11-26 15:08:55 +00:00
drh
eaad533e54 Ensure that all possible outcomes for walIndexPage() are accounted for by
callers.

FossilOrigin-Name: 12715c6b234a04627ca27e94bfa8bd456998360a9f0117480e0038f4747818d6
2021-10-27 23:55:30 +00:00
drh
71c3ea7523 Avoid the 1-based indexing on the WalHashLoc.aPgno[] array. Make it 0-indexed
instead.

FossilOrigin-Name: 28f5f709b4b28ba7f6f56bdd4a9e8c04d0d2df90d13d6df1a589fa4a65163f4d
2021-10-27 20:23:59 +00:00
drh
5f25627a1c Improve the comment on walIndexPage() to more accurately describe the
post-conditions.

FossilOrigin-Name: b619e936455f4001b543a9a58dea2ac9ebd598327d6be01130ca6e7e9764ffe6
2021-10-27 19:57:59 +00:00
dan
9023444fea If an EXCEPTION_IN_PAGE_ERROR exception is caught, make the underlying OS error code available via sqlite3_system_errno().
FossilOrigin-Name: fdb20e9ee48465b94aa6ac3c5e263ecaa7c3b10f4a193e79f965b7c35944b08b
2021-09-10 21:28:56 +00:00
dan
ee7c667a36 Change the structuree exception handler in wal.c to catch EXCEPTION_IN_PAGE_ERROR instead of EXCEPTION_ACCESS_VIOLATION.
FossilOrigin-Name: 0c6ab539cfbc908550fa993a587e85d644b6335853ff9781caae860c461c045d
2021-08-26 21:12:07 +00:00
drh
67ae593ffe Use VVA_ONLY() instead of TESTONLY() in SEH macros so that the build
works for coverage testing.

FossilOrigin-Name: 9e9d5b566da72adf780685ea27da7d76a7274e904a533438255af92875c94503
2021-08-20 18:18:12 +00:00
dan
5b6c3c8f7d Add missing SEH_INJECT_FAULT macros.
FossilOrigin-Name: 27e9bdb3a90a5826f45d32e0378e9afa90a16ac762a75236f38218f41bc45ded
2021-08-20 17:23:19 +00:00
dan
c6effdbfba Add some assert() statements and fix small issues with code on this branch.
FossilOrigin-Name: bd9b373b177a71f5eaeb7ce8dd1dc755b34951ee1376c24652418bb329bfcb45
2021-08-20 16:19:19 +00:00