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.
drh [Mon, 22 Jan 2024 12:56:58 +0000 (12:56 +0000)]
Fix userauth so that it works together with SQLITE_OMIT_SHARED_CACHE.
([forum:/forumpost/0bfc5888a384d430|Forum post 0bfc5888a384d430]).
However, also change to code to issue a deprecation warning whenever
SQLITE_USER_AUTHENTICATION is used.
larrybr [Mon, 22 Jan 2024 01:11:24 +0000 (01:11 +0000)]
Make CLI .dump immune to pragma reverse_unordered_selects, as reported in [forum:/forumpost/c42be01880e961eb|Forum thread "Missing ORDER BY in .dump?"]
dan [Sat, 20 Jan 2024 18:41:13 +0000 (18:41 +0000)]
Ensure that values generated by DEFAULT clauses that specify real numbers that can be expressed as 64-bit integers (e.g. -1234.0) are not silently converted to integers.
drh [Sat, 20 Jan 2024 16:29:19 +0000 (16:29 +0000)]
Rig sqlite3_serialize() so that it will initialize a previously uninitialized
database prior to serializing it, so that it does not have a zero-byte size
and does not return NULL (except for OOM).
[forum:/forumpost/498777780e16880a|Forum thread 498777780e16880a].
drh [Sat, 20 Jan 2024 15:13:13 +0000 (15:13 +0000)]
When doing a text-affinity comparison between two values where one or both
have both a text and a numeric type, make sure the numeric type does not
confuse the answer. This is a deeper fix to the problem observed by
[forum:/forumpost/3776b48e71|forum pose 3776b48e71]. The problem bisects
to [25f2246be404f38b] on 2014-08-24, prior to version 3.8.7.
drh [Sat, 20 Jan 2024 13:18:22 +0000 (13:18 +0000)]
Ensure that the replace() SQL function always returns a TEXT value even
when its first argument is numeric and its second argument is an empty string.
Fix for the issue reported by
[forum:/forumpost/3776b48e71|forum post 3776b48e71].
drh [Sat, 20 Jan 2024 12:13:00 +0000 (12:13 +0000)]
When backing out a character in a constructed string in JSON, first make sure
the string has not been reset by on OOM.
dbsqlfuzz 2fffbea91a5376526ea118d4fe4188c8dd35e317.