Commit Graph

23836 Commits

Author SHA1 Message Date
larrybr
c6e2f2e64d Make CLI complain about incomplete input at EOF. Fix for regression reported at https://sqlite.org/forum/forumpost/718f489a43be3197
FossilOrigin-Name: 72029cf7cdb266703cc8716102dbba8e6f2666e1f47409f42c39528795757b73
2022-03-15 17:57:42 +00:00
drh
836652952f Calling sqlite3_value_dup() on a pointer value results in an ordinary
NULL.  [forum:/forumpost/ae8592cc73|Forum post ae8592cc73].  Test cases
in TH3.

FossilOrigin-Name: fff1243b594c190d15f14b7ca4e60d23519cd15134f275991c685966fcc24145
2022-03-14 23:50:38 +00:00
drh
d024eca323 Fix an assert() statement in the covering index optimization for the corner
case of dealing with an sqlite_offset() SQL function call.

FossilOrigin-Name: 3950b7d006add571579158c751247a9435801e53eafd84b43dd3046e01da8ee6
2022-03-14 22:58:04 +00:00
drh
1a25be1a9a Disable trigger coding while running sqlite3_declare_vtab().
dbsqlfuzz 97e1865771b4226f29e6e482411c1cae14133f50

FossilOrigin-Name: 387ab17b8a0a4b87903aab52abc7da79098b882aff2ab687a554d5794e9d183e
2022-03-14 20:31:57 +00:00
drh
90402d4d54 Foreign key constraint failures should return SQLITE_CONSTRAINT_FOREIGNKEY
even if there is a RETURNING clause.  See
[forum:/forumpost/e6be6e82c86aa59b|forum thread e6be6e82c86aa59b].

FossilOrigin-Name: 3f9887d4a58cbfdbabf2a37e975c81ba660f373414058920b379f3a81e6e1c2c
2022-03-14 16:54:05 +00:00
drh
5a1f761218 Add a comment linking a part of the UPDATE constraint checking code to
one of the corresponding TH3 test cases.

FossilOrigin-Name: 0606e8e93edb5de4d154f377dbf91f15295d25ca9013c0f1612ae6d63a0139ea
2022-03-11 15:42:05 +00:00
drh
27e456458e Fix a harmless compiler warning.
FossilOrigin-Name: 5d739aff96c47146dba72fd76fed62d4e43ded09b32246fdde13d5467f713135
2022-03-11 15:16:50 +00:00
drh
605137aae6 Fix a harmless compiler warning and restore performance in the
sqlite3BtreeIndexMoveto() last-page optimization.

FossilOrigin-Name: 8b032293b384c3728c27b0658ee634c028c0d231d067de8b747d2e9e4ae704a7
2022-03-11 14:20:06 +00:00
dan
7ef4d75bd2 Fix a case in fts5 where a corrupt database could cause a crash.
FossilOrigin-Name: 5e95df261cce275adb5b2226e9584f4c389bb0d53c3b4feafd5a14be8d02ce63
2022-03-11 12:02:18 +00:00
drh
3946561a7f Another corruption detection case in the sqlite3BtreeIndexMoveto()
last page optimization.

FossilOrigin-Name: 531e6ad0389c6c820bb8c64db5049fb6b0bffd30bd394fd8ee7412959b1752e2
2022-03-10 23:37:58 +00:00
drh
463edb6275 In the sqlite3BtreeIndexMoveto() last-page optimization, make sure to return
SQLITE_CORRUPT if corruption is detected.

FossilOrigin-Name: 4ef19ba9b5cbda435c0bb9f2faddf8f7fac5d51399ff69bd049571c2ca3d9357
2022-03-10 22:54:32 +00:00
drh
fde3043200 Stronger defenses against corrupt schemas in the ALTER TABLE logic.
FossilOrigin-Name: 13fbde28173332522a7ad307c1aad2b83c9aa1fe737583afa2b29f6da4de6370
2022-03-10 21:04:49 +00:00
larrybr
551b650236 Amend sqlite3_column_*() doc table. (no code change)
FossilOrigin-Name: 1f473099776249f774a285fa117316636e00c3ff030ba0f22ed5bd05641c1bc9
2022-03-10 19:44:04 +00:00
drh
5e121a50b3 Prevent a NULL-pointer dereference when trying to parse a illegal
schema entry that contains a window function while doing a RENAME COLUMN.
[forum:/forumpost/ec2a2e0deb|Forum post ec2a2e0deb].

FossilOrigin-Name: 58de3c2b1a773a71b2d6a5d9a4dc0f839185d78d64519e7d267ad133b9830120
2022-03-10 16:26:00 +00:00
drh
105dcaa503 Refactor Window.pFunc into Window.pWFunc to disambiguate from other uses of
the variable or field named "pFunc".

FossilOrigin-Name: d9475ebcde169272ad7b1d3a82b2326df55dafc68217bfecd9fcd1f2b89efbd9
2022-03-10 16:01:14 +00:00
drh
7931f0a3d8 Only run atof1.test on x86_64 machines.
FossilOrigin-Name: 4173819cd285a1c133645eda27b9f6dc5a2247eaa0c834bdc60058ef3109b102
2022-03-10 11:48:16 +00:00
larrybr
a1d60e6c8c Mention that sqlite3_column_text16() returns have native endianness
FossilOrigin-Name: 25b7f88fcb2bb1908abde109c1167c462efbb156b4a8a8f94d36202bd93ea433
2022-03-10 02:23:43 +00:00
drh
6a51e70c5f Check-in [642a0b4752743216] fixing sqlite_dbpage is not exactly correct.
This patch should fix it.

FossilOrigin-Name: 6ba36714ca5e5457bc424273129f2814b62b7fae38926aa6eeeeec81020d7f70
2022-03-10 01:10:28 +00:00
drh
6563d0c11a Further refinements to the sqlite_offset() fix from [6029514b08b88e3f].
FossilOrigin-Name: 6f838305e2c848a43b210bd1b7b962fb9e3c41de34de778675e6578fcd99f397
2022-03-09 18:29:19 +00:00
drh
46dc631a32 Fix the sqlite_dbpage virtual table so that it starts a write transaction
on all attached schemas.

FossilOrigin-Name: 642a0b4752743216271e4f855a465515ef7f6a985f280251e18d67e3d5fb694b
2022-03-09 14:22:28 +00:00
drh
b528a5a04e Do not use va_arg() as an l-value, because
[forum:/forumpost/45e39c1311|AIX does not allow that], from what we are
told.

FossilOrigin-Name: 46d1a6de620f26fef9d0e2de6e9ea032790016441e4e6228a2f8cb30e20c9a51
2022-03-09 13:22:53 +00:00
drh
577f0a1e45 Improve the defenses against bad pathnames input into the findCreateFileMode()
function of os_unix.c in order to quiet static-analyzer warnings.  There
are no demonstrated problems in the prior code, but this change makes the code
easier to prove correct and more robust against future changes.

FossilOrigin-Name: a9cda38997a692e25d2fe994a9a3fb9472c00ba04323c82e706fdb1112d4244e
2022-03-09 12:20:40 +00:00
drh
32135d7e0a Fix a minor typo in a comment.
FossilOrigin-Name: cf61419f8816377f40ea032e1e3fb8b765ff7eb5b3a5ece8f7b59acffc5d3f05
2022-03-08 15:49:17 +00:00
drh
e684ac6f12 Fix compiler warnings.
FossilOrigin-Name: 5e30c6ea707f9d381127e8b2bb59e0b39bc00997da2c14d32a0e302d0121203b
2022-03-08 13:59:46 +00:00
drh
ec9b622fbf Disable an assert in moveToRoot() when the database is corrupt.
[forum:/forumpost/e9a176b7bd|Forum post e9a176b7bd].

FossilOrigin-Name: ae464a18d74bf44fc95bc335e75e6a57dc974f6d6a3d603133594039fb589af2
2022-03-07 18:32:08 +00:00
drh
42bb09c412 In the stay-on-last-page optimization for sqlite3BtreeIndexMoveto()
(check-in [0057bbb508e7662b] about 16 hours ago), be sure
to clear the BTCF_ValidOvfl flag, since the overflow cache is invalidated
by the search on the last page.  OSSFuzz issue 45329.

FossilOrigin-Name: 0021bebc162e001b788786703ce634e7b8fcd3976f7047a5956e82140791e765
2022-03-07 17:19:40 +00:00
drh
4c460bbffd Do not allocate new Trigger objects in the parser following a syntax error,
to avoid violating invariants associated with Expr nodes.  See
[forum:/forumpost/2024e94071ef1531|forum thread 2024e94071ef1531] for more
information.

FossilOrigin-Name: 5e0ed49b3d739d292f5df3e498449ae8f4357cbb83394181fb34f98ed8372707
2022-03-07 16:22:31 +00:00
drh
6d6ea42a25 Fix the code generated for vector IN operator constraints on virtual tables
so that they work even if the "omit" field in the sqlite3_index_info object
is off.  This has apparently never worked correctly before.  Presumably, nobody
has ever before written a virtual table that can use vector IN operator
constraints and that relies on bytecode to double-check the constraints.
Test cases in TH3.  Problem discovered by
dbsqlfuzz cab8e26194a40147627094f3c6849c0a7b1e0310.

FossilOrigin-Name: 21b656572d066b640ff5774205a4f0db13e1b08a35d0fd484da9130e759b0c26
2022-03-07 14:51:29 +00:00
drh
c5a55db75d Optimizations to sqlite3BtreeIndexMoveto() avoid unnecessary comparisons if
the cursor is already near the end of the table and is not moving far.  This
case is more common that you would expect.  The optimization saves almost
4 million CPU cycles.

FossilOrigin-Name: 0057bbb508e7662b0da19e981c07ef10236cb616bda952745de3aa2d1c286289
2022-03-07 01:29:36 +00:00
larrybr
41f46703b8 Disentangle variable use in last checkin
FossilOrigin-Name: 4c3a02600f10926da1f88ddbd457bb1486e6e02dee366b5cfc89e498a10daa6f
2022-03-07 00:14:52 +00:00
larrybr
53e1186da9 For CLI .import, revert to importing into temp or main when given table is found there and no -schema option used. And plug an obscure leak.
FossilOrigin-Name: bf9d1278846dce9255f9a11ddfc5dfac1acea2eadcb20816a19d59f7bccaec0f
2022-03-06 23:41:21 +00:00
drh
eab1064f04 Fix obsolete but harmless comments in btree. No changes to code.
FossilOrigin-Name: 4838b888e431f794b8a5ee65e797b3bf0616c03261de4e1fc9499287eb3e1265
2022-03-06 20:22:24 +00:00
drh
97a985e0c5 The sqlite_offset() function should be non-deterministic.
dbsqlfuzz 3df8230bb940870db87ffca2c0fc759c1e7fa356.

FossilOrigin-Name: e1a185e60afd32d3b25278dee42049920759ccd8fe709161007f5daa4a048693
2022-03-06 11:43:06 +00:00
drh
dc9513601e Remove a NEVER() associated with sqlite_offset()>
FossilOrigin-Name: e29dffcdba6f68af5cb76ca250e06a42183d9db92b60a16b2337b0d43c68bf2e
2022-03-05 23:52:05 +00:00
drh
ea840117af Fix the 'localtime' modifier in date/time functions so that it preserves
fractional seconds.
[forum:/forumpost/2ffbaa2c3fd7fb82|Forum post 2ffbaa2c3fd7fb82].

FossilOrigin-Name: 1c875b0764ab00e95c92f0ee329659e88041763e125c2891201d80f68c41f717
2022-03-05 20:12:53 +00:00
drh
8f32d92786 Further improvements to the sqlite_offset() function.
FossilOrigin-Name: 4230e2f5e068f2151fa33be25bb06123d41273dbe497a5ebc7173f8d7f81d160
2022-03-05 19:36:29 +00:00
drh
a275e76696 Fix the sqlite_offset() function so that it gives the correct answer even
if the argument is a virtual column in an index-only query.  Test cases
in TH3.

FossilOrigin-Name: 6029514b08b88e3fb3c0163813af38358490a6b6070b90f69975a324481394e5
2022-03-05 14:44:12 +00:00
drh
768ab1f296 Update obsolete text in the ICU README.txt file talking about SQLite's
robustness (or lack thereof) in the face of corrupt database files.

FossilOrigin-Name: dc88fc62f096bcf4df91406f565197f335333388121f860ba4424d9c881b0117
2022-03-05 11:57:28 +00:00
drh
ff55da360d Do try to evaluate the Bloom filter on a LEFT JOIN early, as doing so
essentially converts it into an INNER JOIN.  See
[forum:/forumpost/544af7eee2|forum thread 544af7eee2].

FossilOrigin-Name: d46d0e67c96bd49add4f71194496804a31209f2027a2e48eaf36dde26c1ca7df
2022-03-04 20:54:09 +00:00
drh
6f9d68817c When setting an sqlite3_value object to a pointer value, make sure any prior
memory allocations associated with that object have been cleared first.
dbsqlfuzz 33f842d1a09afaad5f078c3e1162a54b78e5f2ab.

FossilOrigin-Name: 31e1bde4b20bec4242b4101adad29bfa85648ea703d6e8c5c75e8c49b54a3a0f
2022-03-04 16:28:24 +00:00
drh
07559b2716 Restore the ability to push-down OR subterms of the WHERE clause when
processing a multi-index OR.

FossilOrigin-Name: d71fb6fdc32d2fce73059b6ab86d7d7bbc812c637469755dd45b6794aadc3a80
2022-03-03 19:40:21 +00:00
drh
4f12271780 Make sure the xParseCell and xCellSize methods of the MemPage object are
initialized consistently even if the page is detected as being corrupt.
dbsqlfuzz fd21f341f3b4f582401d2feb2a1c0c4cc2c26caa.

FossilOrigin-Name: 725a06434b886c96bb816340ef236530672a4593f0ceb3230ce69c8367beb997
2022-03-03 16:48:35 +00:00
drh
c9bcc5aab7 Fix for the problem identified in
[forum:/forumpost/0cd8e058bf|forum post 0cd8e058bf]:
When evaluating an multi-index OR, do not push down auxiliary WHERE clause
terms that involve subqueries into the OR-subqueries.  Otherwise, the
covering-index optimizer might convert table-references into index-references
for the particular OR index that is active for the branch in which the
subquery subroutine is coded, and those index-references
will not work if the subquery subroutine is invoked from a different OR branch
that uses a different index.

FossilOrigin-Name: 61a1c6dbd089979cbeb8b0c0c5ee1ab1abcb466be1d21a3a851be73c27e67a6c
2022-03-03 15:59:22 +00:00
drh
1902516d16 Add the new OP_BeginSubrtn opcode (which is really an alias for OP_Integer)
and make other changes so that the span of a subroutine that implements
a subquery is more readily apparent in bytecode listings.

FossilOrigin-Name: b8226748709de37cfc86414714c20567254e5b320b380e767c322dba69a79d49
2022-03-03 15:00:44 +00:00
drh
5694569591 Bloom filter pull-down optimization is incompatible with Skip-Scan.
Make sure the query planner does not try to to both.
[forum:/info/50a1bbe08ce4c29c|Forum post 50a1bbe08ce4c29c].

FossilOrigin-Name: ad3ffa1a75a5a032ebb64d8e014ee0a85c5e44b732e4b11bd67f31a59e729b94
2022-03-02 21:04:10 +00:00
drh
fc854505b4 Faster version of sqlite3VdbeMemRelease().
FossilOrigin-Name: 86c5fa2f301e4bdb538099f654b70b6ba0e214778cba2c53c53844e5d7ca129f
2022-03-02 17:50:59 +00:00
drh
5308d3931e Reinstate the releaseMemArray() performance optimization of
[bb520293d8c11518] with corrections.

FossilOrigin-Name: 1291080d118c678072289a2e57a56b73657e9256ae47eafa7853716c8d47392f
2022-03-02 13:45:22 +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
ceff761521 Fix a harmless compiler warning.
FossilOrigin-Name: 6497997aa80419688890ed5dbbb7d6acc26bf3732305ff4a728cba1fe4d1626b
2022-03-02 01:02:16 +00:00
drh
86af59830f The performance optimizations at [bb520293d8c11518] is not quite right,
so it has to be backed out.

FossilOrigin-Name: 15f73b121cacf77ada02bfe434f9caa1175ac482d007156cfb0864e4221490d1
2022-03-02 00:50:06 +00:00