1
0
mirror of https://github.com/sqlite/sqlite.git synced 2025-04-20 08:47:46 +03:00

1192 Commits

Author SHA1 Message Date
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
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
drh
65d0312c96 Check-in [da9124fee28c155c] broken the new SQLITE_IOCAP_SUBPAGE_READ mechanism
for inhibiting direct-overflow-read.  This check-in fixes the problem.

FossilOrigin-Name: 113078d555eaf740666680562ebbb04f7d823b72e8b2d553627e54ab3d7bf653
2025-01-15 21:13:38 +00:00
drh
bd1a5932d9 Changes for better alignment with the wal2 branch.
FossilOrigin-Name: 4fab85b3d0d1cad2d185f2456de7ddf281badf8561cc051e10e16655441dcc84
2024-12-16 13:25:49 +00:00
drh
deb5ad6297 Reorder conditions in sqlite3PagerDirectReadOk() for coverage.
FossilOrigin-Name: da9124fee28c155c4d1cc0d3949eb7b588a7236c12883a010af7909ad8e534ef
2024-10-23 11:33:56 +00:00
drh
96501c89d5 Rename to SQLITE_IOCAP_SUBPAGE_READ.
FossilOrigin-Name: dd446ef1816f4e95ce29de0b3841dd0a6c983646fd2dd271c2db8f3263478164
2024-10-22 18:26:03 +00:00
drh
c8284c766a Add the SQLITE_IOCAP_BYPASS device characteristic. Do not allow the
SQLITE_DIRECT_OVERFLOW_READ optimization if that capability is missing.

FossilOrigin-Name: f50ae00ce9ff572e6bd5e2788602ba356383526ab7289622a32fbf52926c6df0
2024-10-22 18:00:26 +00:00
dan
a592883d87 Add extra assert() statements to the fixes on this branch.
FossilOrigin-Name: 81b6360050eea95e4367de1b41b5864a640b4d1c5c8fc3bea3b96ed770cb0325
2024-07-17 16:27:36 +00:00
stephan
b6d108f0b3 Fix handling of the SQLITE_OMIT_WAL check in one place. Resolves [forum:87cc13302de160eb|forum post 87cc13302de160eb].
FossilOrigin-Name: 5dae6e6df4921f42e45c6c8de40853ab63f53a4bd1d9088a8cdac957ce62f196
2024-04-11 19:08:12 +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
stephan
09e6c82d56 Update #ifdef checks in pager.c and util.c to account for [0462a2612d1fc1d0] to resolve the build problem reported in [forum:9819032aac|forum post 9819032aac].
FossilOrigin-Name: 0f22d809a1c6c80e381f6bcd931fe4ec36dca0e28d07ab4f4f7f83c813424f60
2023-12-22 15:41:13 +00:00
drh
95cf95841c Avoid harmless integer overflow in pager status statistics gathering.
Response to [forum:/forumpost/7f4cdf23f9|forum post 7f4cdf23f9].

FossilOrigin-Name: 206d8c650d937bc700946c40a82a62ea6bc4a80e5f3fb42d0ae2968de25f0644
2023-12-20 11:34:17 +00:00
drh
5a81e6e5ce Ensure 8-byte alignment of data structues in sqlite3_database_file_object().
This should have appeared on trunk originally and then be cherry-picked onto
the branch.  Oh well....

FossilOrigin-Name: ac39800bb2685fa287c7d834faed75f0bc61320ef986de314392d6eadb574d30
2023-11-10 17:49:26 +00:00
drh
f3f0bd2155 Add a cast to i64 for an integer in an sqlite3OsWrite() offset
calculation.  The cast is not strictly necessary, but it helps human readers
see that the code is correct.

FossilOrigin-Name: 7564ff1ba2c2fba89106d1aa06cc5379e752f119f22370f2f155f24cc698dec6
2023-10-30 19:03:17 +00:00
drh
d2147bd32b With SQLITE_ENABLE_BLOCK_ATOMIC_WRITE enabled, if a transaction is committing
and there is a new freelist page at the end of the database file which would
cause the database file size to grow, ensure that page is written and the
file size grows before the block-atomic-write commits.  Fix for the
problem identified by [forum:/forumpost/3bd8d497b2|forum post 3bd8d497b2]

FossilOrigin-Name: c9fdd6805df04f05ef347e5a43506fd37a729c5924abb6e1103e871c4ac2d6dc
2023-10-30 12:09:48 +00:00
drh
11095bcb89 When an I/O or similar error occurs during a transaction with
journal_mode=MEMORY, attempt to rollback before closing the journal, as
all rollback information is forgotten when a memory rollback journal is
closed.

FossilOrigin-Name: 1d67f75de259e5a26b751a50432822a268ebe367cda6510891ab81a15e5daa1c
2023-10-17 10:47:42 +00:00
drh
5d9a6c6734 Make sure the journal file is closed when transitioning into MEMORY journal
mode, to avoid an assertion fault in the new sqlite3_randomness() avoidance
code added by [c84e4483cb44f827].

FossilOrigin-Name: 29937081a986d88f495ad48748c35ff5829f0ac31dd4ad3e48d180ae2fcb9a0c
2023-10-12 17:41:18 +00:00
dan
6c96bf2c3f Avoid calling sqlite3_randomness and taking the PRNG mutex when writing a journal header in "journal_mode=memory" mode.
FossilOrigin-Name: c84e4483cb44f827416d8caafa22f076b2f31b2024fe8c5b5bcb0c9955149d11
2023-10-09 17:54:34 +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
drh
56a410741b Address various harmless compiler warnings from
[forum:/forumpost/d526da8ee4|forum post d526da8ee4].

FossilOrigin-Name: 365caf2f97e8f15842f52536e8d05d359e9d6e863182e020ce14a9a9f27ee057
2023-06-16 14:39:21 +00:00
drh
2e4d526996 Fix the pager such that if the xOpen() message sends back the SQLITE_OPEN_MEMORY
flag, the pager is opened in journal-mode MEMORY, even if compiled with
SQLITE_OMIT_DESERIALIZE.  No changes to the logic as long as that OMIT flag
is omitted.  We need to better document the behavior of xOpen to describe this.

FossilOrigin-Name: da1252b29852191eccbea98e0314408c75bb83a51f9d68d589705d4971a23850
2023-06-16 11:05:49 +00:00
larrybr
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
larrybr
bc91738e66 Add a C-source spell-checking facility. make misspell (on Nix)
FossilOrigin-Name: 26c1bb4bd9e9f56613c3aa87407a7f562fd4ebde5bfd6dece02078001d9a45f8
2023-06-07 08:40:31 +00:00
drh
28f32bedd1 It turns out that pagerExclusiveLock() can be called with the lock state
already set to RESERVED if the SQLITE_FCNTL_PERSIST_WAL setting is set and
a specific sequence of multiple journal mode changes occur.
Enhance pagerExclusiveLock() to deal with this.
[forum:/forumpost/8130545bc6|Forum post 8130545bc6]

FossilOrigin-Name: 2bb8d977392f635515aa4a36f6f763a2e4858f7adc1120519e2e74c04a9749b5
2023-05-07 03:23:32 +00:00
drh
2c5c124064 Do not remove pages from the cache of an in-memory database due to a
failure to acquire the page due to it being larger than the maximum page
size. Fix for [forum:/forumpost/a19bb49140|forum post a19bb49140].

FossilOrigin-Name: 982b35563da685dfdf50cbe4a7ae829d3b428e03587028df7efe520f819b1dc2
2023-04-19 15:35:45 +00:00
drh
ec0ed68846 Fix ambiguity in the header comment to the sqlite3PagerUnrefNotNull() routine.
No code changes.

FossilOrigin-Name: d419e65eef2954ed759121254024028854b55e8c4f52ff7a8896c8cadfc57f53
2023-04-19 14:26:43 +00:00
drh
d9ae63144e Add pager debug tracing of truncate operations.
FossilOrigin-Name: 0daadf36229816abe73ff684b55ef4f8045ed314347f3a694404a2084decb355
2023-04-19 13:30:17 +00:00
dan
5c84aafd77 Fix compile time option SQLITE_DEFAULT_SYNCHRONOUS so that it works consistently.
FossilOrigin-Name: bf6f1ee77c4bf653f6cd2a3db5292b8c5c83f18ea9acf951107d22807546b28a
2023-02-13 18:26:58 +00:00
drh
5db5c122ef Remove an ALWAYS() that can be false in some very rare cases.
dbsqlfuzz 2274a23c85a93b870f7eb12fe686073da01abc33

FossilOrigin-Name: a4eb0b0d837291590958a5f292f41e80e0f722668a060aebfed5ea36ea176332
2023-02-04 20:07:52 +00:00
drh
989d0cec5d Attempt to fix harmless compiler warnings that reportedly appear in clang 15.
FossilOrigin-Name: c045d76b908a8c90d22511df7884e78d452b250db9ba70d4cb0935048a3c3ac4
2023-02-03 14:57:40 +00:00
drh
f648389a2e Suppress a harmless compiler warning.
[forum:forumpost/e3f72e9291189925|Forum post e3f72e9291189925].  The code
was legal and correct. The revised code is actually less clear in its intent.
But at least now there will (hopefully) be no warning.

FossilOrigin-Name: 48bb7c88787bf5de1d70cf3cc81ada38c6c02e476dbdff12c8676c6d5ee19aed
2023-01-23 21:41:41 +00:00
drh
cf3107c7d4 Databases created using sqlite3_deserialize() should report their filename
as an empty string, not as "x".  Fix for ticket [53043c9793715f08].

FossilOrigin-Name: ff494449efd475878c549728cc22ee9b12d13674068781747fc042a0c1bd09c8
2022-11-19 00:08:35 +00:00
dan
ad617b4d6d Ensure the Pager.journalOff variable is zeroed if an error occurs while writing the initial header to the journal file.
FossilOrigin-Name: da7af290960ab8a04a1f55cdc5eeac36b47fa194edf67f0a05daa4b7f2a4071c
2022-09-02 21:19:24 +00:00
dan
2756f806f2 Add assert() statements to verify that the SQLITE_OPEN_EXCLUSIVE flag is always passed to the VFS when opening a temporary file.
FossilOrigin-Name: e123da49ccae61d591abded52f4721aa10f20d75935c9a3e3fe826a9b8df2317
2022-08-16 10:52:35 +00:00
drh
b2d7137154 Back out the pager performance enhancement at [a1c090e08139f99d3], because it
turns out we should never allow a zero key into the pcache interface according
to the design specs, even if that page is immediately released without ever
being used.

FossilOrigin-Name: ec96293ead83603ebe5d7f250d6fdc11f22172f05a9513f175331437c3eaa4c8
2022-07-12 07:13:38 +00:00
drh
16316f1b68 In the getNormalPage() routine of pager.c, consolidate pgno error checking
into a single spot for small size reduction and performance increase.

FossilOrigin-Name: a1c090e08139f99d30aa89db0756dc59fe8990ce15b3db4d4b726cc6acdab46f
2022-07-04 09:41:44 +00:00
dan
bbf71138cf Add missing SQLITE_FCNTL_SIZE_HINT call to a path taken during transaction rollback.
FossilOrigin-Name: 6c3266c1b4fc446c7c3a40a8816caf4f9fe0cafe4f27cdafecac61425a17927e
2022-06-14 21:34:13 +00:00
drh
e3994f2975 The optimization at [ece326db50201937] is not quite right, so back it out
for now.

FossilOrigin-Name: b218a4b9fe44ffc5cb8d2a2491a5aad217d37b26ccc6b04caf8f28b71bcfe809
2022-03-02 11:39:11 +00:00
drh
90368c5dcb Increase the max_page_count on ROLLBACK, if necessary, so that it is sufficient
to cover the entire database.  Fix for the problem identified by
[forum:/forumpost/3b9e894312|forum post 3b9e894312].

FossilOrigin-Name: 12c012162ce110a7a7fbbe853f422e23cb4ae10b45237727328c8f3315b70842
2022-03-01 14:13:32 +00:00
drh
eac750e9a6 Defer the check for error check Pgno zero until after the page fetch misses,
to gain a few CPU cycles and a small size reduction.

FossilOrigin-Name: ece326db50201937eb688809df39edc7fb97413b4614d2e2e783418192f7b02a
2022-02-23 17:16:30 +00:00
drh
584bfcaeb6 Store the page number for the PENDING_BYTE page in the Pager object, rather
than computing the page number every time it is needed, because it turns out
that number is needed quite frequently.  This saves a few hundred thousand
CPU cycles and a few bytes of code space.

FossilOrigin-Name: 5aa9c3eb45514d5eb7b32696d25a9aeb7dad485e1ea5adb833fac6d1f2105f1a
2022-02-23 17:00:44 +00:00
drh
e63b7bdac8 Generalize the in-memory journal so that it is able to accept writes that
begin at any offset less than or equal to the current file size.

FossilOrigin-Name: c039d5476e0836c16d8c1ad99a2620f7fd04eb4b0e5dcb2246b42dde2ae1f95a
2022-02-14 21:11:17 +00:00
drh
4ba1c5cc49 Fix an assert() in the pager by adding "|| CORRUPT_DB", in as much as the
assert() is not necessarily true if the database size in the header is
wrong.  dbsqlfuzz f2f996065b90988aa9b0ae425b66dbb296546a08.

FossilOrigin-Name: a51402e8c29fad2b24e32de55b10691fb0ebd6c2cebac941e43e54be211d5d39
2022-02-11 17:33:02 +00:00
drh
e2adc0eea1 When process first moves a database into WAL mode and then tries to run
sqlite3_wal_checkpoint() without first performing a transaction, first
try to run a synthesized transaction to get the Pager caught up before
attemptingn the checkpoint.
[forum:/forumpost/fd0f19d229156939|forum post fd0f19d229156939].

FossilOrigin-Name: eee6de1967609f0b590ee4dbec088c3e7b03b08753267ed2909c5b03d60a0e18
2022-02-09 18:47:09 +00:00
drh
9f4ce3b19f Writes to the subjournal should be all-or-nothing. Fix for
dbsqlfuzz fe3c397fb90029313446c4e0f4a6cd0c81dd9621.

FossilOrigin-Name: 22cc55e84f67f6f39b7dba07a4ef7ae958b2d926633faec91a278922053e50c6
2022-02-08 15:14:18 +00:00
drh
5a6f818d84 Never allow the b-tree layers view of the number of pages in the database
file exceed the actual number of pages in the database file, even when
PRAGMA writeable_schema=ON.  This helps with earlier detection of corruption,
and prevents excess memory usage and CPU cycles in some integrity_check ops.

FossilOrigin-Name: 0407c8793700491b8519a649b9624f569b0e7e9b94d0db79d4a08139e0ecdb69
2022-01-17 14:42:38 +00:00
drh
5622c7f971 Add NEVER() macros to two branches that became unreachable due to
[e199a851e316bd47].

FossilOrigin-Name: 71272caff5874137ad0b1ddfc22ced4bb66e6c97f7868fdae0347a186f589b38
2022-01-08 21:50:00 +00:00
drh
bda4d20080 Do not open a rollback journal file when the journal_mode is OFF, even if
such a file exists on disk. See
[forum/forumpost/ec2a102440|forum post ec2a102440] for a description.  I so
far have been unable to find any harm to come of the problem, other than the
assertion fault when in DEBUG mode.

FossilOrigin-Name: fdf9ed665b2fb07d26f3852bfd2170f2fb56851edd2851d47672116a8ea58463
2022-01-02 19:32:43 +00:00
drh
d0fa3484c6 Improve formatting of an assert(). No functional changes.
FossilOrigin-Name: 4bb78ce8b50af3c6f04ffdf4de4438e61370a73ccfa971479af5d58a0a7e5fbb
2022-01-02 19:10:49 +00:00
dan
4ce289d088 Fix an assert() in pager.c to avoid the possibility of side-effects.
FossilOrigin-Name: 1d1fe03c752267f03f015ada975876f65e2a7b967e19f057b5c73f95d7df8a9c
2022-01-01 20:02:58 +00:00