drh [Tue, 20 Feb 2024 12:48:00 +0000 (12:48 +0000)]
Enhancements to PRAGMA optimize and ANALYZE. Add the 0x10000 flag to
PRAGMA optimize. ANALYZE now records zero-size partial indexes in the
sqlite_stat1 table. PRAGMA optimize looks for both growth and shrinkage
in table sizes, and uses tighter bounds (10x rather than 25x) to trigger
a re-analyze. PRAGMA optimize automatically uses are reasonable
analysis_limit to prevent excessive runtimes.
drh [Mon, 19 Feb 2024 16:22:58 +0000 (16:22 +0000)]
If a table has one or more rows and it has a partial index has zero rows,
still make an entry in the sqlite_stat1 table for the partial index, so that
we know that "PRAGMA optimize" does not need to redo the whole table.
drh [Mon, 19 Feb 2024 13:50:09 +0000 (13:50 +0000)]
Simplifications to PRAGMA optimize to make it easier to use. It always
tries to ANALYZE unanalyzed indexes. The 0x10000 flag just makes it check
for size changes in all tables.
drh [Mon, 19 Feb 2024 13:06:27 +0000 (13:06 +0000)]
Change the 0x20000 bit (use analysis limit) to 0x10, meaning that this feature
is on by default. The default analysis limit is changed to 2000 which is
almost always sufficient for accurate analysis results.
stephan [Mon, 19 Feb 2024 12:20:46 +0000 (12:20 +0000)]
Extend the strerror_r() result type discrepancy check in os_unix.c to include the Android NDK, as reported in [forum post 3f13857fa4062301|forum:3f13857fa4062301]. The NDK's strerror_r() signature is version-dependent, whereas this change assumes int return (POSIX semantic) across all versions.
drh [Sat, 17 Feb 2024 03:32:31 +0000 (03:32 +0000)]
Fix rounding in zero-precision %f and %g printf conversions.
[forum:/info/393708f4a8|Forum post 393708f4a8]. This bug was
introduced by check-in [32befb224b254639] and first appeared in version 3.43.0.
drh [Fri, 16 Feb 2024 21:30:08 +0000 (21:30 +0000)]
Fix the subtype on the value column from json_each/json_tree for cases
when the value is an array or object. Fix for the bug reported by
[forum:/forumpost/ecb94cd210|forum post ecb94cd210].
drh [Tue, 13 Feb 2024 18:41:46 +0000 (18:41 +0000)]
Fix a bug in PRAGMA integrity_check introduced by enhancement (8a) in
[https://sqlite.org/releaselog/3_42_0.html|release 3.42.0] and first reported by
[forum:/forumpost/ee4f6fa5ab|forum post ee4f6fa5ab].
drh [Tue, 13 Feb 2024 17:11:19 +0000 (17:11 +0000)]
Changes to vtabCallConstructor() to avoid a harmless static analyzer warning
and to help prove that the UAF reported by
[forum:/forumpost/cafbe582e8|forum post cafbe582e8] is a false-positive.
drh [Sun, 11 Feb 2024 20:53:14 +0000 (20:53 +0000)]
If a term of an ORDER BY or GROUP BY contains an aggregate function or column,
then it is not an alias that needs to be resolved, so don't try to. This fixes
a harmless assertion found by dbsqlfuzz. This yet another problem that
orginated at check-in [6e6b3729e0549de0].
dan [Mon, 5 Feb 2024 17:54:03 +0000 (17:54 +0000)]
Return SQLITE_ABORT if the underlying shadow tables change in the middle of an rtree query in such a way as to invalidate an rtree internal priority queue entry. This replaces the SQLITE_ABORT_ROLLBACK mechanism added in [af5c4251].
dan [Mon, 5 Feb 2024 17:35:36 +0000 (17:35 +0000)]
Return SQLITE_ABORT if the underlying shadow tables change in the middle of an rtree query in such a way as to invalidate an rtree internal priority queue entry.
drh [Sat, 3 Feb 2024 19:19:18 +0000 (19:19 +0000)]
Following a ROLLBACK that reverts changes to an RTREE, any pending queries
against that same RTREE abort with code SQLITE_ABORT_ROLLBACK.
dbsqlfuzz de7d17b72d0e842352c998dd86a47b7d0f707be9.
drh [Thu, 1 Feb 2024 14:17:01 +0000 (14:17 +0000)]
Add tracing logic to the shared-cache locks in btree.c. The tracing is
off by default. Enable by changing a single "#if 0" into "#if 1" and
recompiling. Debugging code only - no changes to release builds.
drh [Wed, 31 Jan 2024 15:20:13 +0000 (15:20 +0000)]
Add NEVER() and ALWAYS() macros for the JSON5-control-character change.
Also fix an incorrect comparison used to determine if a buffer needed to
be resized.
drh [Mon, 29 Jan 2024 12:50:32 +0000 (12:50 +0000)]
When rendering JSONB back into text JSON, report an error if a zero-length
integer or floating-point node is encountered. Otherwise, if the node occurs
at the very end of the JSONB, the rendering logic might read one byte past
the end of the initialized part of the BLOB byte array. OSSFuzz 66284.
drh [Sun, 28 Jan 2024 17:39:31 +0000 (17:39 +0000)]
Automatically disable the DISTINCT optimization during query planning if the
ORDER BY clause exceeds 63 terms.
dbsqlfuzz afd1d61fc27d14938a0d78a50970fa1e9fbfee58.
drh [Sat, 27 Jan 2024 11:35:35 +0000 (11:35 +0000)]
Allocate new parser stack space from the heap if needed, eliminating the
possibility of a "parser stack overflow" error as long as heap memory is
available.
drh [Sat, 27 Jan 2024 02:21:25 +0000 (02:21 +0000)]
Optimizations to ParseFinalize() to make up for the extra cleanup associated
with the allocated parser stack. This branch now runs faster than trunk
and is less than 300 bytes larger.
dan [Tue, 23 Jan 2024 16:09:22 +0000 (16:09 +0000)]
In os_unix.c and os_win.c, do not allow xFetch() to return a pointer to a page buffer that is right at the end of the mapped region - if the database is corrupted in a specific way such a page buffer might be overread by several bytes.
drh [Tue, 23 Jan 2024 13:51:55 +0000 (13:51 +0000)]
When a JSON input is a blob, but it looks like valid JSON when cast to text,
then accept it as valid JSON. This replicates a long-standing bug in the
behavior of JSON routines, and thus avoids breaking legacy apps.
[forum:/forumpost/012136abd5292b8d|Forum thread 012136abd5292b8d].
drh [Tue, 23 Jan 2024 13:21:40 +0000 (13:21 +0000)]
If a BLOB looks like JSON when cast to text, then treat it as if it really
were JSON. This replicates a long-standing bug in the JSON processing
routines, and thereby avoids breaking legacy.
drh [Mon, 22 Jan 2024 14:16:10 +0000 (14:16 +0000)]
The -DSQLITE_JSON_BLOB_INPUT_BUG_COMPATIBLE compile-time option causes blob
inputs to JSON functions that are not JSONB to be processed as if they
where text, immulating historical bugging behavior which some applications
have come to rely upon. See
[forum:/forumpost/012136abd5292b8d|forum thread 012136abd5292b8d] for
discussion.