Commit Graph

26004 Commits

Author SHA1 Message Date
drh
d9eb39e625 Early out from sqlite3Prepare() following an OOM to avoid possible
problems further along in the parse.  Fix for the NULL pointer dereference
reported by [forum:/info/2e5131839365682a|forum post 2e5131839365682a].

FossilOrigin-Name: f35ce7c122017009496b777f33e641d0be086abee6ea8e25aab4c3e0fb45731a
2023-04-22 11:29:36 +00:00
larrybr
8bfa190e9a CLI to handle absurd string length limit better. [forum:5180af725f1cc375|forum post 5180af725f1cc375]
FossilOrigin-Name: 1489e7f53a4863b316af6dee10d9c66491d1bed6cf52a3538ac118c03b1d7ef9
2023-04-22 11:24:52 +00:00
larrybr
c40a7c82fa Avoid need for cast in CLI shell_check_oom() calls.
FossilOrigin-Name: c88550ef6711b03a81e2e6d121e2eb99ccff6e925c025dd6e85dd81088508400
2023-04-22 09:26:36 +00:00
larrybr
5870e942c2 Fix unchecked return in CLI .dbi command. ([forum 79e2cd1bc](forum:)79e2cd1bc)
FossilOrigin-Name: 81a74ee9d66ba23dfadd875e372ce96491dd6bf146e03e7fec8c3fd98e6be825
2023-04-22 09:14:22 +00:00
stephan
0e38c6e696 Change the return type of the ts_read/write() family of functions from int to ssize_t, per report in [forum post 947169d5e7](forum:947169d5e7).
FossilOrigin-Name: 7809e7ce6a70657b8ea239eb4778698f7986a658e9177a57b2fb7814c069c936
2023-04-21 15:37:33 +00:00
larrybr
88ed723490 Increase CLI tolerance of arifically low memory.
FossilOrigin-Name: 13f2638622871db9b91db547dcfd38f61c03e7696e4df5144adefcd86140aeba
2023-04-20 20:07:14 +00:00
larrybr
1829f34f46 CLI .ar made to enforce getting a proper subcommand.
FossilOrigin-Name: 104ab105ac0e96c0fc61c6d69179bf984fcfe5e0efb2c82f3742456c1b5fe5d1
2023-04-20 16:15:20 +00:00
drh
5eca6ffe5c Fix a function declaration so that it correctly appears as private in
the amalgamation.  [forum:/forumpost/ec8c77516c|Forum post ec8c77516c].

FossilOrigin-Name: 1864569bb9fe28a5e77f34b199f26ac272dbbb1a6642dacd7e50ddd29aa567b6
2023-04-20 10:40:37 +00:00
dan
9549245509 Fix a broken assert() in the recovery extension. [forum:/forumpost/82a88f5812|Forum post 82a88f5812].
FossilOrigin-Name: 8a1ad137606ce5bddbed62f89ff9a5cd922c6530db84c12b8b27c08df3c66bc6
2023-04-20 10:26:56 +00:00
dan
8cb4f0b1b2 Add tests for the progress-handler callback with the fts5 'secure-delete' feature.
FossilOrigin-Name: 48505ad950bc0902d58210be066d4672e6085eb27c525ba2bc663fde7e932ff7
2023-04-19 20:29:26 +00:00
drh
f23adcbaa4 Improved rebustness of the pcache tracing logic.
FossilOrigin-Name: 0a43235b8368a0996d1856c4e956786a5321275458cb9179ce818aa47bb824ed
2023-04-19 18:36:49 +00:00
drh
2cc723a2da Remove unreachable legacy code.
FossilOrigin-Name: e3e7fb87d90690c29b70da261887c8f7d87b62188d15577e48db91232e13608c
2023-04-19 18:32:32 +00:00
dan
3115b36d67 Fix a segfault that could occur if a non-empty in-memory database was the destination of a backup operation from a database with a smaller page size.
FossilOrigin-Name: 020968f857d7b90bab3525fc9d6b859a019f6a80422c3d5ffb88f5bdb8e02a11
2023-04-19 17:07:35 +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
4c0fca00d3 Fix a debugging printf() in pcache.c. This only comes up on custom builds.
FossilOrigin-Name: f2d6756731caadf9a30214ab7d19717a2ca1dae2652bcc6b211f6b0830362240
2023-04-19 13:56:47 +00:00
stephan
b669956637 Correct use of an undefined symbol in one of the OPFS VFS loading failure error reporting cases (copy/paste error).
FossilOrigin-Name: c81c968b458977b2d6dd2fdd3c3d667f0e7cee069f3715363d0e8aed4e6e8377
2023-04-19 13:39:13 +00:00
drh
d9ae63144e Add pager debug tracing of truncate operations.
FossilOrigin-Name: 0daadf36229816abe73ff684b55ef4f8045ed314347f3a694404a2084decb355
2023-04-19 13:30:17 +00:00
drh
e61aa230ce Attempt to suppress harmless compiler warnings reported by
[forum:/forumpost/fc98845c06|forum post fc98845c06].

FossilOrigin-Name: f6e6c5f94cef83645288568a344a0ff64e4ef17b10fab28996567a94db0a002a
2023-04-19 12:08:46 +00:00
larrybr
cbba7e61d6 CLI to cease dumping back to OS shell on single ^C when interactive.
FossilOrigin-Name: ba8e4378f21d529a248d2d60b60974fef0d6612dcaaa1f6b7f8a6946fc46b39b
2023-04-18 23:05:34 +00:00
larrybr
837b661f2c Add comment on CLI ^C fix (because it is a bit subtle.)
FossilOrigin-Name: 19c062f1cd814a33bf9c10928217464cddaea7c3291ff44e605901a86b82a06d
2023-04-18 22:53:30 +00:00
larrybr
7b1a49c993 CLI to cease dumping back to OS shel on ^C.
FossilOrigin-Name: 7b1f635268bd5b093b22f832c3ac9e5d642d1aac5ebc620619be5a24930feb83
2023-04-18 22:28:48 +00:00
drh
359c5ac1fb Ensure that the VACUUM command is not confused by alternative encodings when
it is the first command run on new database connection.
[forum:/forumpost/09503b4d33|Forum post 09503b4d33].

FossilOrigin-Name: 8b0fe63f873661037351fc1eba6071b98b5c97a0fc8bd8a504a90d047f78bc0d
2023-04-18 15:21:55 +00:00
drh
f84aeac274 Another fix to the indexed expressions in aggregate queries with GROUP BY
enhancement of ticket [99378177930f87bd] and implemented by
check-in [b9190d3da70c4171] to address a problem described by
[forum:/forumpost/f34e32d120|forum post f34e32d120],

FossilOrigin-Name: 5acc3ef83e16a9f2803981a6e61eca62fe177cac4eed1befe2ade3a5977a1eab
2023-04-18 14:13:54 +00:00
drh
053a29c291 Add the --fullsync option to speedtest1.
FossilOrigin-Name: 960fe54c8227a376c97bb2a3ba604d97e79e27e51a9798be9d318cf56c04fa99
2023-04-18 11:35:09 +00:00
dan
a5eab9579a Fix an assert() in fts5 that could fail following an OOM or IO error.
FossilOrigin-Name: 49595083ba58e13d404b6a11c28f53768a257c59f3f36be3591438127df7e875
2023-04-18 11:33:35 +00:00
larrybr
ab4af9c368 When CLI -utf8 active, do no translation to MBCS for output to Windows console. plus code style improvements
FossilOrigin-Name: 25edf6089724bf9f97c796e5abf838ec508ebc132895d8325620c16d63996fef
2023-04-17 23:59:15 +00:00
mistachkin
acb4050cfc Minor coding style changes.
FossilOrigin-Name: 481aa3ccf6f12c2c2fd11a1a20d8fb59f4f9b1cd8dcff0586b4f52222463d720
2023-04-17 22:28:02 +00:00
larrybr
690ebc6908 When CLI -utf8 active, do no translation to MBCS for output to Windows console.
FossilOrigin-Name: cc1d4296d71ee6e2ba133edc581385e201c89657911c2ed39108843c776633a4
2023-04-17 21:18:53 +00:00
dan
68c0da6f66 Fix some problems with using fts5 options 'secure-delete' and detail=none together.
FossilOrigin-Name: 4d3f27ba90aa59837e49ceaae9f36cad426af3a33707d85d1bb848fc1bda6fed
2023-04-17 18:32:22 +00:00
dan
48824f23cb Fix problems handling corrupt records in new fts5 code.
FossilOrigin-Name: 2f63d4a8bac6dc72197df32efd84c148adbc4794943088dff08da57b15dd7900
2023-04-17 11:41:42 +00:00
dan
5c45a9fbaf Fix an assert() in fts5 that may be true when dealing with corrupt records.
FossilOrigin-Name: e8de2774463c07b76cd6b9a44ab32a583fe973f42a21b21af46fe82ab177c1b8
2023-04-17 10:39:51 +00:00
dan
ae6f6ef3b0 Change a memcpy() to memmove() in new fts5 code.
FossilOrigin-Name: 8de4542553ae20947787b4daf5e88bbe69f815679960e700e19f9c1148234b08
2023-04-15 21:00:55 +00:00
dan
0e429cf934 Fix a use-after-free that could follow an OOM or IO error in fts5 when using 'secure-delete' mode.
FossilOrigin-Name: 904be83d9f3dd4b21a3aa47dde337b5c045b925ffdde4bccd1f8e8fdbef68c18
2023-04-15 19:58:58 +00:00
dan
e45317a50a Avoid dropping the error code following an OOM in fts5 when using 'secure-delete' mode.
FossilOrigin-Name: 9ee24a499c7b4a048f269f1c03c7c0b22b2898a3c23ea3e2511c2ba0342afa30
2023-04-15 19:13:51 +00:00
larrybr
a8e9a7763d Add -utf8 option to CLI, for improved console behavior on Windows.
FossilOrigin-Name: 414010d2366477285cb238f7af1e3d511ab4cda4bd4493441bd9868387dd5b66
2023-04-15 17:56:43 +00:00
dan
7dcc3dfc04 Add the 'secure-delete' option to the fts5 extension. For configuring fts5 to delete old entries directly from the full-text index instead of using delete keys.
FossilOrigin-Name: 394980e4fe12125460ab14da41edae9089a4da332a46f3124bf0b9778793791f
2023-04-15 17:47:32 +00:00
larrybr
9726db69e6 For CLI -utf8, set output codepage too. Adjust PP vars so that the code can be entirely omitted for targets pretending to be "WIN32" but not quite doing so.
FossilOrigin-Name: 543594a7277b12d1c58af8e3cba3841667cf924172995536489ce7da704a11d7
2023-04-15 16:12:46 +00:00
larrybr
5f347a426d Fix stray edits in comments in last check-in.
FossilOrigin-Name: fa3ce7f013d40147f012e26d0ede75b134174f144d314336310c9ac585e23fb7
2023-04-14 21:34:58 +00:00
larrybr
cdb8a698c1 Set CLI -utf8 option and build with line-editing package to be mutually exclusive. Integration of console-invasive UTF-8 handling with line-editing takeover of console may come later.
FossilOrigin-Name: 047344a91583f273a55fe3659bb8020ffc947c05c4274fbda54ee0608e62adb1
2023-04-14 21:23:08 +00:00
larrybr
67f678138d Cure CLI double-prompting (by ditching gcc fgetws()), general cleanup. Work remaining is to avoid effect of -utf8 when a line editor is linked/used as part of CLI.
FossilOrigin-Name: 73a5f54231e9f6ad8f013df3987ea48c516080f9193ed873b56f982ee75658c2
2023-04-14 19:56:32 +00:00
dan
112500028e Further tests for fts5 secure-delete mode.
FossilOrigin-Name: c5a47063b7971868ebbb3f0718434dd6bd22d01c43697f48941df9aae3885abc
2023-04-14 18:00:03 +00:00
dan
3fc123b7bc Add extra OOM test for the new code on this branch.
FossilOrigin-Name: 846ae7e099ce67dab6b5df0ad5648a01d7bf7f2acf8312d817ed8505d4ea5aec
2023-04-14 17:00:29 +00:00
dan
d36106c954 Add tests for the new feature on this branch.
FossilOrigin-Name: 0268d1a59316d169927cbd4c562725e46a9023b7d7123ade911c12203e222adf
2023-04-14 16:11:05 +00:00
dan
41334cf960 Fix SQLITE_OMIT_VIRTUALTABLE builds of testfixture.
FossilOrigin-Name: 430ec1a61507d8afd8adc161f577f32856dba21506db9717fae3d14570786439
2023-04-14 14:36:34 +00:00
dan
95dc3e08bd Update test script recoverbuild.test so that it may be run using old test harnesses that run more than one test script in a process.
FossilOrigin-Name: 5135aab0c0ab39f3b9cc84efbbc57f7266b42d98134fc0c5dace06f707374195
2023-04-14 13:34:26 +00:00
drh
deabd6969b When setting the column types on a subquery, ensure that the COLFLAG_HASCOLL
flag is cleared from column names from when the collating sequence name has
been removed.
[forum:/forumpost/6916dacf83|Forum post 6916dacf83].

FossilOrigin-Name: 8d9dcd7cfdd53034e21cdb2cb997b6f5fe3207ca5d0d7a0b841b8a68e6ce8624
2023-04-14 10:40:50 +00:00
drh
a73f51447b Fix a cosmetic indentation issue.
FossilOrigin-Name: 90deb84486494b903bab065fbf0174b56483c190353992b907359661393f2c54
2023-04-14 10:35:29 +00:00
drh
2142b7c0a6 Avoid double de-quoting of table names when processing RESTRICT actions
in foreign key constraints.
[https://bugs.chromium.org/p/chromium/issues/detail?id=1405220|Chromium 1405220].

FossilOrigin-Name: bb2b5ab172f0751c00343facf36fb12db10c88220caece31849f2711f12293d9
2023-04-14 00:20:16 +00:00
drh
731a1aaeb2 Fix an obscure issue with ALTER TABLE RENAME that comes up with triggers
that have UPDATE statements that contain errors.
[forum:/forumpost/ff3840145a|Forum post ff3840145a].

FossilOrigin-Name: c4845a7c5f7f219848d3ee32eef0f9c69ad6dc6e8509da84d612f41e1e05f007
2023-04-13 18:44:59 +00:00
dan
8efa288f99 Add extra test cases to window1.test.
FossilOrigin-Name: ebc844fbfb046c5789efe21fd607c9301cb7b3d78edef72b2926b8c889b048a9
2023-04-13 14:53:19 +00:00
drh
017bdf7838 Fix a code-generator issue associated with very unusual use of window
functions.  Both the expr.c or the window.c changes will each
independently fix the problem.  They are both included in this patch for
defense in depth.  [forum:/forumpost/0d48347967|Forum post 0d48347967].

FossilOrigin-Name: 1ba22631a7831e3562eda0eb6a5edf7f009c85c7ab4451d9eacd13ef0fb6036a
2023-04-13 14:50:50 +00:00
larrybr
4e87950b48 Get CLI utf8_fgets() to not consume more input than it returns. Get console setup restoration to happen for all non-crash exits.
FossilOrigin-Name: b4fa233d3dda54fa83771844cf5156bf1275c687925340af17a7713a9400dfef
2023-04-13 14:14:27 +00:00
drh
3f4a319934 Unwrap the loop in the WAL hash function.
FossilOrigin-Name: eb94ae13206762a42ddad12e0d1461df83e9759e44a369f188cd3aad82f211c4
2023-04-12 20:23:03 +00:00
drh
be0023faba Automatically set HAVE_PREAD and HAVE_PWRITE on linux, as has been done in
MacOS for a long time now.

FossilOrigin-Name: 2f7a36d2c374100019bd9d38aea51ea10cfcf9b1f0330ba084a75f0773df8ebf
2023-04-12 19:40:00 +00:00
drh
6b507423a0 Small performance enhancement to integer-to-text conversion.
FossilOrigin-Name: cfb3dba9b015ce7a75857978bfd2540b4d5be985d9d2ec4a5842b3089ed3da60
2023-04-12 18:57:50 +00:00
dan
7877dca93f Avoid leaking a database handle in test script rbuexlock.test.
FossilOrigin-Name: 2edf98d128cabc0c9de1295470d7f87eb64e4cc1f13344fe3c198fcf9c7bf019
2023-04-12 18:18:28 +00:00
dan
02877e9558 Remove temporary debugging code accidentally left on this branch.
FossilOrigin-Name: 0a0f64870feaf95d2673efc8884ad1236d9bbf9bdb94364f8d2602221bd36ff3
2023-04-12 18:06:43 +00:00
larrybr
ad5a7da489 WIP: CLI option to take control of console on Windows and make it support UTF-8 input pasting (or typing). Needs work to become robust per "ToDo:".
FossilOrigin-Name: 824382393d92d9eb6df8701de7c263280150569a708759c4a539acc6d8d38821
2023-04-12 17:54:52 +00:00
dan
015020cd1a Add the 'secure-delete' option to fts5. Used to configure fts5 to aggressively remove old full-text-index entries belonging to deleted or updated rows.
FossilOrigin-Name: 4240fd09b717dbc69dffe3b88ec9149777ca4c3efa12f282af65be3af6fa5bb0
2023-04-12 17:40:44 +00:00
drh
67f3765876 New #ifdef to enable building with -DSQLITE_OMIT_WINDOWFUNC.
FossilOrigin-Name: e1ff83fa2565334b28bd0d6582088c4ae0d2d9a590d973615a4a598683fe419c
2023-04-11 19:38:47 +00:00
drh
82aacda7eb Remove an ALWAYS() that can sometimes be false. Add a test case that makes
the test false.

FossilOrigin-Name: c8fb143d64d8e823684cd26799080da4b42bef121ca3c6315b1803a593490926
2023-04-11 15:06:20 +00:00
drh
e4d8e7e5df Better handling of OOM errors in the cursor-hint logic.
dbsqlfuzz 60cd5fff91974af91c2c3692beb4a2d7fdafef46

FossilOrigin-Name: 68fcfb58df837b40e401dfa4e505f4f0b87554b9cfeb2c527f3558348b73c1be
2023-04-11 02:10:34 +00:00
larrybr
69881887b8 For sha3 extension, mention NIST standard implemented.
FossilOrigin-Name: 529ab138a438379f0cbd170bff5211aee1c327a1b3119a714ee15f68fd2239f3
2023-04-10 23:21:19 +00:00
drh
ed36917835 New assert() statements to validate the parameters to
sqlite3BtreeCursorHint().  Fix a problem with the construction of those
parameters discovered by
[forum:/forumpost/0b53708c95|forum post 0b53708c95].

FossilOrigin-Name: 4c5a3c5fb351cc1c2ce16c33314ce19c53531f09263f87456283d9d756002f9d
2023-04-10 18:44:00 +00:00
drh
8346f8dacc Sync the vt02.c test virtual table with TH3, in order to pull in the fix
for long delays when there are huge OFFSET values.

FossilOrigin-Name: 49ba030080dd00b4fdf788fd3da057b333e705fa0fe37d653e2461bf96ca3785
2023-04-10 13:20:51 +00:00
drh
d27c18818c Fix an assertion fault that can occur when compiling with both
SQLITE_ENABLE_UNKNOWN_SQL_FUNCTIONS and SQLITE_ENABLE_STAT4.

FossilOrigin-Name: 9ff69e599817610d14948a3eebcc4d3c18245f78a1433c23ae659211cbbdb017
2023-04-09 20:44:09 +00:00
drh
d4fe3c77e6 Fix a faulty assert() in whereRangeScanEst() that should only apply if there
are not prior errors.
dbsqlfuzz 567ad91132879cbab8172b38c6a68ad40fa8d650.

FossilOrigin-Name: 8ba9b08bd976ed2c024f5f378b4dd40a55226e950af77c476c21273fccaf7e26
2023-04-09 10:09:28 +00:00
mistachkin
1a2f490fbc Fix a couple harmless compiler warnings seen with MSVC.
FossilOrigin-Name: 1b864a370fd04bba11487e3dab0388394bc71e1f3f006f7bd9d64eefe04e8b61
2023-04-08 19:27:03 +00:00
drh
df3944ecb8 Fix a typo in [83e84531b46814ae] that changed the value of
SQLITE_DBCONFIG_STMT_SCANSTATUS.

FossilOrigin-Name: b71776539183e5fd8678ce8f3272180d3dbb8214ed7b7bb24d35c0ba027a6ac5
2023-04-08 19:23:13 +00:00
drh
9e0181fcf7 Faster implementation of keywordCode() - the routine that determines if an
identifier is really a keyword and if so, which keyword.

FossilOrigin-Name: 0ff3d3d53709b7f18bf01ded1f988e41b7f8471072cf4f2702a3a8b79964be3f
2023-04-08 16:51:08 +00:00
drh
a9b20c0937 Fix a harmless compiler warning.
FossilOrigin-Name: c9559ba62191fe7fa2a718233afaa841e2594d1fc833314bf5b0a6b775e87c35
2023-04-08 13:31:17 +00:00
drh
2da07d9025 Optimizations to btree.c save about 4.5 million CPU cycles:
(1) Clone insertCell() into a separate insertCellFast() routine for
use by sqlite3BtreeInsert().  (2) Mark allocateSpace() as always-inline.
(3) Improved coalesence of adjacent free blocks in pageFreeArray().

FossilOrigin-Name: 5c12c400fe8eb4e86e14c69a6c34d0d78d9861e5d40a36c6a596a81c6dd65977
2023-04-08 13:01:34 +00:00
drh
65aae44b87 Guard against oversized cells in the newly enhanced pageFreeArray().
FossilOrigin-Name: 2dcdbb50356edbd3a79e53fa0bee4e700c2bdea78e27173b62ddabe44b066726
2023-04-07 18:27:32 +00:00
drh
3da5e2a9f3 Add NEVER on an unreachable branch.
FossilOrigin-Name: 9b3febbd988be05807ada20146d3e196ae17c966722fff049feb32292157bff2
2023-04-07 16:30:33 +00:00
drh
81e31c9c2b Fix an assert().
FossilOrigin-Name: 7eff46ba97dd8a3d6a5d01d5d61e98a2805deceafa47335eded7d784a8304525
2023-04-07 15:49:42 +00:00
drh
706c33d9ba Tweaks to the new insertCellFast().
FossilOrigin-Name: 203a581a9177c1083e8d5b49e8ff026af33b5c5e3e144aeda126f07a3a2953bf
2023-04-07 15:07:58 +00:00
drh
34ceb7e622 Clone insertCell() into insertCellFast() for use by sqlite3BtreeInsert() for
a substantial performance increase.

FossilOrigin-Name: f225afd90c8e65661d8b855050f0ee1a8fe4c0f3bcec824aa5a66d906f3c7119
2023-04-07 14:33:33 +00:00
dan
6d47af64e4 Fix a problem causing the rbu_exclusive_checkpoint=1 to be ignored with zipvfs databases.
FossilOrigin-Name: d8f50b31e8d64fce5141da4a016767a15482703364692a55df346f059fc9d30c
2023-04-07 14:03:30 +00:00
drh
b39f037ca5 Small performance improvement in freeSpace().
FossilOrigin-Name: 8dc5292ee592f16451441e33ad0800ba10a21ecd63f1f9926d6915a59a1552d3
2023-04-07 13:21:20 +00:00
dan
1e24f9f1f3 Add further tests for the rbu_exclusive_lock=1 URI option.
FossilOrigin-Name: c07b62bef96bb69e9b1ce08f0084fdce8de981f4d8ea9689c87a41f1e4451ac7
2023-04-07 11:18:08 +00:00
drh
50dc8d9720 Increase the size of the cache of free blocks inside of pageFreeArray() to
reduce the number of calls to freeSpace().

FossilOrigin-Name: 27c59f1ea789f3ff245f23e79ded5cd71c48e3a51ffbb8c220b51101a4e69fd7
2023-04-06 20:14:10 +00:00
drh
82412051db Work around a harmless assertion fault associated with
sqlite3VdbeMemAboutToChange() such that the detection of stale values
in registers is preserved in debugging builds, but we avoid a false-positive
assertion fault in cases involving a virtual table with a LIMIT clause
in an IN-operator loop.
dbsqlfuzz 3fd70d4ab4950acf1deb8f610a7a7c67cd38713b

FossilOrigin-Name: 56ea2c2fe6108d39833ac40957afab59ade01a216639d5bafdeeca53bbf4cd67
2023-04-06 17:29:38 +00:00
drh
ebec9c475e A prepared statement that aborts due to SQLITE_SCHEMA should not invalidate
cursors in other prepared statements that are already running.
See [forum:/forumpost/cae4367d9b|forum post cae4367d9b] for the original
trouble report.

FossilOrigin-Name: 857d0f5e16ba69ac9e5ee581befca2f7ed933edfe6e36396b10dae7979b44a57
2023-04-06 13:35:42 +00:00
drh
5482afd6cf In the CLI, during error processing while looking for a word boundary,
avoid being deceived by malformed input that has a very long sequence
of 0x80 characters.
[forum:/forumpost/ab93a23ba1|forum post ab93a23ba1].

FossilOrigin-Name: 82609d5a2d4eba741d48ea265f4e749578964961903c072c7b222ffe2aefaa3c
2023-04-06 01:05:52 +00:00
drh
c6349ce205 In the zipfile extension, defend against corrupt ZIP files that contain
a zero-length filename.
[forum:/forumpost/b15f5e3ad8|Forum post b15f5e3ad8].

FossilOrigin-Name: 46db2e42a5f9b18da9661ccedca68cb70257ea5c58b33b401db2a5e030c1346a
2023-04-06 00:59:41 +00:00
drh
1ba1806637 In the new .scanstatus command in the CLI, make sure the database is opened
before invoking sqlite3_db_config().
[forum:/forumpost/6e26dcf544|Forum post 6e26dcf544].

FossilOrigin-Name: 1cd993c45cd6b60e00d1426dd01d63efad13f7258636b5fa694f21499e77955a
2023-04-06 00:18:31 +00:00
drh
072a02ce2c Add a test case for the ALWAYS() macro removed by the previous check-in.
FossilOrigin-Name: 68a1a837493a0bc5e0e0f2373ac76cb575078cec08990c017fdcb51a4ba363a1
2023-04-05 02:55:08 +00:00
drh
9d10ba8b1f Remove an ALWAYS() that might now be false due to the prior check-in.
FossilOrigin-Name: fc68993501aaa7180f5457dcb3c296e5b199904a385d98e2bcad7854e34d428e
2023-04-05 02:50:00 +00:00
drh
8907cb2f88 Fix the function that determines the collating function for an expression
tree to handle new cases that arise as a result of the recently added
ability to use indexed expressions in aggregate queries.
[forum/forumpost/0713a16a44|Forum post 0713a16a44].

FossilOrigin-Name: cc5041f3f067cf610adffb868b4e2d1b5d248dc5a0ecc551339b670800ecb0ff
2023-04-05 02:21:57 +00:00
larrybr
c6c4bae80a Shell to use SQLITE_SHELL_HAVE_RECOVER consistently (correcting check-in 0421cc03e0efa8f1)
FossilOrigin-Name: 5b980d72a03fa1cfd0f1bf3ed04068b9f216b75a304deb2b7bbe8ddce0e6fb96
2023-04-04 19:56:28 +00:00
drh
cd0f540761 Fix an incorrect entry in the array that maps sqlite3_value values into
actual datatype numbers.  dbsqlfuzz f660c659bcec48577a43d3bab37f46baaa22f59e

FossilOrigin-Name: fa8537dc90cad962dec695418d48da2890a172801ecad0c7c804023a063d3a02
2023-04-04 18:55:31 +00:00
drh
c6a54f418c Remove an assert() statement that is no longer valid due to enhancements
to query planner for improved use of indexes.
[forum:/forumpost/dc16ec63d3 |Forum post dc16ec63d3].

FossilOrigin-Name: 2b23dd249d0bc254308f5539936d33ee558f1100dec616caac7317dbe70db761
2023-04-04 18:10:23 +00:00
stephan
20537f0dc7 Expose the new SQLITE_VTAB_USES_ALL_SCHEMAS to JS.
FossilOrigin-Name: b7ef09be667dd349e195842304c03cbebb1693164e1c3587a5d7c96baa713edf
2023-04-04 17:35:38 +00:00
larrybr
0d3651bd85 Omit shell call to sqlite3_dbdata_init() when it is omitted.
FossilOrigin-Name: 0421cc03e0efa8f1a83e46e91f26837366c10eef0903d099e25eb0cc99c297df
2023-04-04 08:49:22 +00:00
drh
39b07f1afc When translating arguments of aggregate functions into references to
expression indexes, make sure to only translate them for the current
aggregate when there are nested aggregates.
[forum/forumpost/409ebc7368|Forum post 409ebc7368].

FossilOrigin-Name: 898bfa1afd8260eaaf2aa6db94e74d99ebf4e8a6dc02cf21d20cd981393609a5
2023-04-03 23:49:00 +00:00
drh
f61bf3dbe8 Improved diagnostic output from PRAGMA vdbe_addoptrace.
FossilOrigin-Name: 050958c1828f7446e7ee7e458123a23b735e213b76a67c3dd8356da256cbc170
2023-04-03 20:11:06 +00:00
drh
555970bf83 When changing a COLLATE expression node into TK_AGG_COLUMN because the nodes
value is contained in an indexed expression, be sure to clear the
EP_Collate property from the expression node.  Fix for the assertion faults
reported by [forum:/forumpost/e45108732c|forum post e45108732c] and
[forum:/forumpost/44270909bb|forum post 44270909bb].

FossilOrigin-Name: cf6454ce26983b9c3ae924c44a802f3f760eaaae9547b40aee9e14e7b0c47cab
2023-04-03 17:46:14 +00:00
drh
0669d6ebbf Add the SQLITE_VTAB_USES_ALL_SCHEMAS option to sqlite3_vtab_config(). Update
the sqlite_dbpage, sqlite_dbdata, and sqlite_dbptr virtual tables to make
use of that interface.  This was formerly handled by the internal
sqlite3VtabUsesAllSchemas() routine that was called directly from sqlite_dbpage.
But since sqlite_dbdata and sqlite_dbptr are an extension, an external
interface to that functionality had to be provided.
dbsqlfuzz 1a29c245175a63393b6a78c5b8cab5199939d6a8

FossilOrigin-Name: bcd51abee0b0f82bb5dbb881025a92d55baf9df6adeaf3a305e2e0da96a81d58
2023-04-03 15:01:37 +00:00
drh
5517538a9c Make the sqlite_dbdata and sqlite3_dbptr virtual tables accessible to
the CLI.

FossilOrigin-Name: c0eff02854d469bcdb949c09531760d6f96b49c17375abd1c131d41f38b9b2f0
2023-04-03 12:48:51 +00:00
drh
d8c34e3311 Stronger constraint checking in allocateSpace().
dbsqlfuzz 93d4c9ff5ef7cd29f16e767af1ee71c29ec5a4c0

FossilOrigin-Name: 9e968f4fbce061190f10f31ce9d3eb4fce6706ea6b7e5011bfa1e893d37ca68d
2023-04-03 12:33:12 +00:00
drh
6455a7066e With the -DSQLITE_ENABLE_JSON_NAN_INF compile-time option, non-standard
JSON numeric values "Inf", "Infinity", "-Inf", "-Infinity", "NaN", "QNaN",
and "SNaN" are all accepted.  SQLite should never generate these values,
but it will accept that with the appropriate compile-time option.

FossilOrigin-Name: 0a050e9013331595e13ca9f859180057b59291c70a6cedb6230eefb25956df9e
2023-04-02 20:56:29 +00:00
drh
c406ecc662 More off-by-one errors in the new JSON parsing.
FossilOrigin-Name: dbc99662087b63c9ed5b398535a6091fc2c5e507907dd1fcb7ad0b6ab3f17144
2023-04-02 20:46:24 +00:00
drh
26cc3a1387 Fix an off-by-one error in the recognition of -Infinity.
FossilOrigin-Name: f7ebf3e6286ddc8cdaa9446235407785d1be2be2d9992e21ef59fcd655f68432
2023-04-02 20:27:02 +00:00
drh
af33654533 Earlier detection of corruption in sqlite3BtreeDelete().
dbsqlfuzz a4c48c291d6e40157a1b749a05eaa7c7faf5a625.

FossilOrigin-Name: 978dc71c388b37740da38c310674315c7d7fe814d1daa16a146b4df71385d1e1
2023-04-02 16:43:20 +00:00
larrybr
756c6cf281 Clear executable bit on base64.c
FossilOrigin-Name: ec1ddbce7db270afc25f71546fa745935ad74bc72920fccfcb37e98649612bf2
2023-04-02 14:53:59 +00:00
drh
8d1005a593 Allow special floating-point value names in JSON: "inf", "-inf", "infinity",
"-infinity", "nan", "qnan", and "snan".  All are converted into valid JSON
values: 9e999, -9e999, or null.  Requires the SQLITE_ENABLE_JSON_NAN_INF
compile-time option to operate.

FossilOrigin-Name: fc8793e5acac7351749e360c6bace5d5a8b3de3aa600ae23e260557db650c461
2023-04-01 23:29:59 +00:00
larrybr
4d5a5a48c5 Swat grammar nit on README.md
FossilOrigin-Name: 715c00e58b774d6a29e2f60fd33a2ecb960307192ae1fdb8ed396f74fd62b444
2023-04-01 16:14:50 +00:00
drh
54b81e36ff Fix harmless compiler warnings.
FossilOrigin-Name: a4fb2864fe01cce9694242a0750623ca47fcecd68f74c4239d3eb5fbf978770a
2023-04-01 15:51:21 +00:00
drh
e5ea81ae85 Improved error messages from PRAGMA integrity_check. Identify the root of
the tree when a problem is found in a b-tree, making it easier to track the
problem to a specific table or index.

FossilOrigin-Name: a1cb152e69c7c6cdd99300c91a8104716089de459d9d19e33ef38432aad70908
2023-04-01 13:14:53 +00:00
drh
2e89f1cdeb In the b-tree module use %u instead of %d to print unsigned quantities such
as page numbers and offsets.

FossilOrigin-Name: 33ac62d8eec56eb71f20ccd28a5d6e4e8051522feb2db0199abee9e18ce1f64e
2023-04-01 12:22:57 +00:00
drh
1839b7990d Omit the the count-of-view optimization if there is a HAVING clause.
dbsqlfuzz 6a107e3055bd22afab31cfddabc2d9d54fcbaf69

FossilOrigin-Name: babe2b5e59647ac9db4601e67c25190aac14eb76d5fcb9fa5b3692b955fefd61
2023-03-31 23:48:59 +00:00
drh
567b069e42 Earlier error detection for index expression usage by aggregate functions.
dbsqlfuzz 29214ace4e25c98d2ddff8fbcf97afdda23f28b9

FossilOrigin-Name: 8e841e7f025f7205959453875f2d9db36271642045593970a2b2fc20b2f847c3
2023-03-30 19:05:48 +00:00
drh
09db37c022 Omit a branch that is no longer needed following [c9c4f287652933eb].
FossilOrigin-Name: 960a488a2db92f5437bc8171cdbed44618d9381c57fd41b2f0e357b6012c80b5
2023-03-30 16:08:54 +00:00
dan
53ed383075 Fix an error in new test script test/aggfault.test.
FossilOrigin-Name: 8724fe7426da55d19dba7b30e09321ba30c73286513864cb05de32f72e50ee31
2023-03-30 12:19:38 +00:00
dan
8fe84a40c7 Fix a crash that could follow an OOM error while processing aggregate functions.
FossilOrigin-Name: 804435a2731bd3c26278c47098854b9ee7727a686587f6208e793738fbfc0555
2023-03-30 11:05:36 +00:00
dan
e1afa2bd24 Avoid having OP_SeekScan jump over an OP_IdxGT or OP_IdxGE that follows the OP_SeekGE opcode. Fix for [b50528af4468237c].
FossilOrigin-Name: c9c4f287652933eb6262a3419efe7e7288f55d3db7e2ac032eeae025f665d306
2023-03-29 21:58:06 +00:00
dan
7b56e97866 Fix a problem with sqlite3_stmt_scanstatus() from within an SQLITE_TRACE_STMT callback made from within a trigger.
FossilOrigin-Name: 1fa78fafa1340de458546526b03cf8b3e9c823913c4225d7c747ad182df5c0fc
2023-03-29 18:54:01 +00:00
drh
0dc43fd4c8 Another #ifdef to omit code that is only used by STAT4.
FossilOrigin-Name: 445c75567de9bf9c8075dfc62c60dc4abeefab59c7803a5ef2cc5d69c08d7633
2023-03-29 15:16:29 +00:00
drh
a9fd5f224c New #ifdefs to omit code that is unused except under STAT4.
FossilOrigin-Name: 09a9b30ba7828a487a33a3ebf8028dfaa147dff67d2724584123b90a88d9814b
2023-03-29 14:42:11 +00:00
drh
df542e0500 Enhance PRAGMA integrity_check so that it can detect that a NOT NULL column
contains a NaN value and report that as an error.
dbsqlfuzz f144b642fe6f1a1c196f258ac6e60118a0cb59b2.

FossilOrigin-Name: 7638d9755dc90fd353b874d03ed418fa8aaee4440290ff69b1b552eae84e5baa
2023-03-29 11:36:24 +00:00
drh
e1be2b7ad9 Fix a weird corner case in aggregate function processing that results from the
recent addition of support for index expressions on aggregate queries.
[forum:/forumpost/bad532820c|Forum post bad532820c].

FossilOrigin-Name: c34fd9fe1b76e0a5943f014f46141cbe55d41bb1e6980adf9bcb6785a03e7883
2023-03-28 16:02:28 +00:00
drh
3cbf38c783 Fix multiple problems with RETURNING on a DML statement against a view,
all inspired by [forum:/forumpost/dc3b92cfa0|forum post dc3b92cfa0].
(1) Do not allow a RETURNING clause to trick the code generator into thinking
that the view being updated has an INSTEAD OF trigger.
(2) Generate all result columns for a view in a DML statement.
(3) The automatic covering index for a view should cover all result columns
of the view.

FossilOrigin-Name: c8bedef0d61731c29ae34de1594222d15b578f9e2cddbbd5b74fb3059644fe0f
2023-03-28 11:18:04 +00:00
stephan
fc6c3936aa Remove a meaningless JS test. Add a timer to the OPFS async-side worker loader in an attempt to catch a browser-specific quirk in which the worker loading silently fails, per discussion in/around [forum post a708c98dcb3ef|forum:a708c98dcb3ef].
FossilOrigin-Name: 4fc1904b8e18c7d41fa65490ced125f1df4f0c22c13de957b24615ed09b3ecb7
2023-03-27 13:57:08 +00:00
drh
3594b2b303 Do not allow constant factoring during PRAGMA integrity_check, since the
constants might be stored in registers that are later reused for other
purposes.  dbsqlfuzz dc9ab26037cf5ef797d28cd1ae0855ade584216d.  Problem
discovered by a new assert() statement added in [6f8b97f31a4c8552].

FossilOrigin-Name: 0bba27b78112b2b2271e498f41c437df985aa2faab302ee5b29d9b60003a8379
2023-03-27 13:24:02 +00:00
drh
aa9192e6aa Improvements to register allocation, especially in the ANALYZE command.
New assert() statements added to help verify that memory allocation is
correct, and to help fuzzer find lingering errors.

FossilOrigin-Name: 6f8b97f31a4c8552312b4c98432ea356ae54c06d9cc929969f50c3c88360cd7b
2023-03-26 16:36:27 +00:00
drh
418f947b98 Disable factoring of constant values during ANALYZE. This is a temporary
fix for [forum:/forumpost/07de5f6216|forum post 07de5f6216].  The register
allocation logic in ANALYZE needs to be completely refactored, but that will
take longer.  This check-in will serve to resolve the issue until a better
fix can be devised.

FossilOrigin-Name: c3967d1259f1df969d303394986960bd098e174dcd337e374c9c3c39e0efa466
2023-03-26 11:54:51 +00:00
drh
b900f9e6e8 When the left table of a RIGHT JOIN is used inside an aggregate function and the left table employs an index on expressions, then make sure the expressions evaluate to NULL for the cases where the left table should be NULL. Fix for
[forum:/forumpost/9b491e1deb|forum post 9b491e1deb].

FossilOrigin-Name: ffe23af73fcb324df988a00be343654ce7078b7208647c4eb779d666b8297e7c
2023-03-25 23:52:05 +00:00
drh
debc3202c6 Add usage detection to the NULL value generator for the left table of a
RIGHT JOIN inside of an aggregate.

FossilOrigin-Name: 4d05a009dfb63bcb4173da4d09ccc00c308ce4dd2534a32aeb23c5d8d6a1fd4b
2023-03-25 23:40:21 +00:00
drh
7bb842642c When reading sqlite_stat4 data during query planning, be sure to expand
zeroblobs prior to running comparisons.  Fix for the issue identified
by [forum:/forumpost/5275207102|forum post 5275207102].

FossilOrigin-Name: 5c8dd8dfcaab9c364b3a126ca35880ef57f5cecbe030771e646c934c8cf43709
2023-03-25 22:37:23 +00:00
drh
de0416171b When the left table of a RIGHT JOIN is used inside an aggregate function
and the left table employs an index on expressions, then make sure the
expressions evaluate to NULL for the cases where the left table should be
NULL.  Proposed fix for [forum:/forumpost/9b491e1deb|forum post 9b491e1deb].
More testing an analysis needed - there is a FIXME in this check-in.

FossilOrigin-Name: 3572b40a7dfc4acc35e72e08e79f64688f8737e57ac89e4d10e6b32bd5178c63
2023-03-25 21:01:11 +00:00
drh
28ae195658 In the byte-code, when the result of an expression needs to be in a particular
register, always use the sqlite3ExprCode() routine because it has the smarts
to know whether to use OP_Copy or OP_SCopy.  Do not try to OP_SCopy inline
because an OP_Copy might be required.  Fix for the problem identified by
[forum:/forumpost/5522082cfc|forum post 5522082cfc].

FossilOrigin-Name: c104e5c6eeb89575319d9f94f49446142b06912fa8b283c19d46aa2ccddc5bda
2023-03-25 19:44:25 +00:00
drh
52786ec185 Add the tag-20230325-1 comment that was omitted from the prior check-in.
FossilOrigin-Name: a13c01d076d23f0de500e8e6283e803dfc96f0da7509c0d97d598d6b3e7b930b
2023-03-25 18:41:42 +00:00
drh
4924e82863 The fix at [2bf5413dc2c19d5f] was incomplete in that it failed to clear
the reusable register cache that might contain registers in the STAT4
buffer region.  This additional change corrects the problem.
[forum:/forumpost/83cb4a95a0|Forum post 83cb4a95a0].  Test case in TH3.

FossilOrigin-Name: 5d554e4d0f59a4309fed40e4fb26c7be42f1d4d55ccdcaaf7b4d445aa3122955
2023-03-25 18:31:24 +00:00
drh
e5895333dd Even tighter bounds on the maximum length of the filename for
sqlite3_load_extension().

FossilOrigin-Name: 787291414d2d2082a3c63e7cdd6bec4719f0c8b75ad1355f5026932ecbb28ba8
2023-03-25 12:27:36 +00:00
drh
12b954db7a Tighter constraints on the maximum length of the filename handed over
to sqlite3_load_extension(), due to
[forum:/forumpost/a43074729e|forum post a43074729e].  This is a
follow-on to [01f3877c7172d522] and
[forum:/forumpost/08a0d6d9bf|forum post 08a0d6d9bf].

FossilOrigin-Name: 9f351bdee2a09a4419bb8256a13d1f757b3e00ec26a445523f224fc56d9ae26d
2023-03-25 03:17:08 +00:00
drh
2c16ec829b New test case to further validate the fix at [221fdcec964f8317].
[forum:/forumpost/d34ad68c36|Forum post d34ad68c36].

FossilOrigin-Name: a6e218a6e1ddd74be6a313b1d336334071747efd4ecd354ed7efe303d09c849c
2023-03-25 02:07:20 +00:00
larrybr
86b67f09e7 Fix CLI non-handling of OOM reported at [forum:/forumpost/6872514e04|Forum post 6872514e04].
FossilOrigin-Name: 6f6a0fd63b13cb827d6a402de01a701eb5b3f92954032ea80e78ec864861a26c
2023-03-25 01:29:40 +00:00
drh
62e43b25dd Remove undocumented, vestigial SQL functions in the CLI that were once used
for the ".recover" command but are now no longer needed.

FossilOrigin-Name: 1ef461aa4e95d254c2c1edebbbfd92ca96d752e04f68ebe70104e8d936d36be9
2023-03-24 22:17:59 +00:00
drh
338ff1ceca Fix possible integer overflow in bounds checking for the debugging function
"shell_int32()" found in the CLI.  This change does not affect the core
SQLite.  [forum:/forumpost/be9c294ee0|Forum post be9c294ee0].

FossilOrigin-Name: 6211471138a654641a4cf4831cfa3b470e06f29a2b77e4d58177c8e065bec11e
2023-03-24 21:35:48 +00:00
drh
ed8e12e97b Fix an error in the OP_SeekScan opcode added by check-in [4a43430fd23f8835].
Problem reported by [forum:/forumpost/8cc1dc0fe9|forum post 8cc1dc0fe9].

FossilOrigin-Name: 651a13fcd16f03e89eb6228c9f3250e25910b9bbe2637f627f65ff78f8ba2059
2023-03-24 21:24:52 +00:00
drh
b3ad5444d0 Fix the handling of indexed expressions in an outer query that appear as
corelated values inside an aggregate function within a subquery.
[forum:/forumpost/79cf371080|Forum post 79cf371080].

FossilOrigin-Name: d8259877eaa962e6f90675790d3770ef02bd1a5d86d319cd8c1834710df844c4
2023-03-24 20:35:56 +00:00
drh
d23924d1ea Fix a problem in cursor-hints for WITHOUT ROWID tables used in a RIGHT JOIN.
[forum:/forumpost/591006b1cc|Forum post 591006b1cc].

FossilOrigin-Name: 221fdcec964f8317b2c23e926cc23799615cd3b4239a8a9ff87a83588d05bc64
2023-03-24 19:17:25 +00:00
stephan
4a1c8ed725 Add a JS test which checks for the issue described in [forum post 895425b49a|forum:895425b49a].
FossilOrigin-Name: 98d30400e4721b1d48ff601698ced146052654f8c6de7c014d4d239bb2dbef43
2023-03-24 17:15:15 +00:00
drh
28fe02cd51 Fix byte-code register allocation in ANALYZE for STAT4 when there multiple
indexes with differing numbers of columns.
[forum:/forumpost/bc39e531e5|forum post bc39e531e5].

FossilOrigin-Name: 2bf5413dc2c19d5feb32e5b01aa9b990ec2f74f45f5ca0dca15215f8c9dbc9b9
2023-03-24 16:57:21 +00:00
drh
c03dbc5a24 The attempt to bring STAT4 up to 100% MC/DC at [55a26c67ed4a3a93] and
at [168fa2fb22b8c1ad] are incorrect.  Back them out and replace them with
a simple NEVER() macro.  Error reported by
[forum:/forumpost/dc4854437b|forum post dc4854437b].

FossilOrigin-Name: 5992370a89f8de7a6e941130b381f85d369856dbdb7860405e6fb17dad2293df
2023-03-23 10:54:07 +00:00
stephan
2255d89f0a Internal cleanups in JS code. No functional changes.
FossilOrigin-Name: 8fbdf7d10400c4f54fc3d8bc823f97818de860deeeed35ab6ad717260cd301e0
2023-03-22 19:57:19 +00:00
drh
ad99243846 The floating-point-to-text conversion with the zero-padding option now
renders NaN as "null".

FossilOrigin-Name: ad59fa17663bda54ec5d4e48ac24e04b87daa70c795d840cd8db382e2dd581b9
2023-03-22 16:55:35 +00:00
drh
5e04d26a3d For consistency, the ".mode json" output from the CLI now renders infinity
in the same format as the JSON functions.

FossilOrigin-Name: abee339d5eae8b63d9579b7ec3a25f18071e675223e0bb5294c733fb618a3a26
2023-03-22 16:37:17 +00:00
drh
c408c155d7 The double-to-text conversion renders infinity as 9e999, so that JSON
output is compliant and so that values can be round-tripped.

FossilOrigin-Name: b52081d0acd07dc5bdb4951a3e8419866131965260c1e3a4c9b6e673bfe3dfea
2023-03-22 16:24:17 +00:00