]> git.ipfire.org Git - thirdparty/sqlite.git/log
thirdparty/sqlite.git
3 years agoexpose sqlite3_{deserialize,serialize}() in sqlite3ext.h extapi-serializing
larrybr [Tue, 22 Mar 2022 03:03:13 +0000 (03:03 +0000)] 
expose sqlite3_{deserialize,serialize}() in sqlite3ext.h

FossilOrigin-Name: da874180d35aacdeb9c06f5b425e8909d833e2765179c4337854d56b8a624fd5

3 years agoCreate new branch named "extapi-serializing"
larrybr [Tue, 22 Mar 2022 02:53:34 +0000 (02:53 +0000)] 
Create new branch named "extapi-serializing"

FossilOrigin-Name: a1220a2170a09075a42d1d6c4b502ffa7cc92856779b9eb2ecb9e05c09ccedac

3 years agoDo not allow an #ifdef inside of an assert(), as gcc tells us that is
drh [Mon, 21 Mar 2022 20:08:13 +0000 (20:08 +0000)] 
Do not allow an #ifdef inside of an assert(), as gcc tells us that is
not portable.

FossilOrigin-Name: c7a2047e93df36c172be0be773f9a04150dafe7ba1773269d74016418d262fc4

3 years agoSome branches are no longer reachable after the previous change. Mark them
drh [Mon, 21 Mar 2022 18:48:31 +0000 (18:48 +0000)] 
Some branches are no longer reachable after the previous change.  Mark them
accordingly.  Also improve comments.

FossilOrigin-Name: 88d69f60cceb22bde42cfe43c23259c7bad47b8e06f918a79bd089a77b480d46

3 years agoStrengthen the defenses against corrupt databases in the
drh [Mon, 21 Mar 2022 18:17:09 +0000 (18:17 +0000)] 
Strengthen the defenses against corrupt databases in the
sqlite3BtreeInsert() function of the btree module.
[forum:/forumpost/c7ec29905f|Forum post c7ec29905f].

FossilOrigin-Name: 4df301c8610c4c36b4eb360d49ccaef873c63ea719ccb14b357754ff0b3ea5ef

3 years agoThe previous assert() fix was not correct when building with
drh [Mon, 21 Mar 2022 15:42:42 +0000 (15:42 +0000)] 
The previous assert() fix was not correct when building with
-DSQLITE_ENABLE_OFFSET_SQL_FUNC.  This is the fix.

FossilOrigin-Name: c0a4767fef27cfe4fdc1d8a29342998095894769a63d84e37ec47ced7ce4e5f7

3 years agoFix the assert() that attempts to verify that the table-reference to
drh [Mon, 21 Mar 2022 13:47:15 +0000 (13:47 +0000)] 
Fix the assert() that attempts to verify that the table-reference to
index-reference translator finds all required translations.
[forum:/forumpost/929168fdd6|Forum post 929168fdd6].

FossilOrigin-Name: fa9bd1fce47e8db1cfc4cd8efd2c09f8711ea917ce7d116dc7226c575cb9a6d4

3 years agoFix an assert() in sqlite3TableAffinity() that might have been false if there
drh [Mon, 21 Mar 2022 11:32:45 +0000 (11:32 +0000)] 
Fix an assert() in sqlite3TableAffinity() that might have been false if there
was a prior syntax error in the query.

FossilOrigin-Name: 23fdb169ca1622369cd44fd641946c37fef09071625838b3b9c86c31244ed205

3 years agoIn the CLI, disable the zipfile and sqlar extensions in --safe mode.
drh [Sat, 19 Mar 2022 15:19:35 +0000 (15:19 +0000)] 
In the CLI, disable the zipfile and sqlar extensions in --safe mode.

FossilOrigin-Name: d8b65a2dab97392ff81bcc33ff707b4e626a10d84a258c6452e45f90cd2c7f45

3 years agoFix the zipfile extension so that it knows that a zero-length BLOB returns
drh [Sat, 19 Mar 2022 12:48:14 +0000 (12:48 +0000)] 
Fix the zipfile extension so that it knows that a zero-length BLOB returns
a NULL pointer.
[forum:/forumpost/ae86934905|Forum post ae86934905].

FossilOrigin-Name: 5f6d56737caefa78e542a7af2f95646e3a818e0ecdd8e838f3c2978500ce960c

3 years agoChange a conditional into an assert() due to the change in
drh [Thu, 17 Mar 2022 23:49:58 +0000 (23:49 +0000)] 
Change a conditional into an assert() due to the change in
[387ab17b8a0a4b87].

FossilOrigin-Name: 13b584869f40ea6aa2190dbac64709695ee8d72b27bc5afb8b39ab3763b9c46a

3 years agoAdd a 4th output code (value 3) from the sqlite3_vtab_distinct() interface
drh [Thu, 17 Mar 2022 22:09:17 +0000 (22:09 +0000)] 
Add a 4th output code (value 3) from the sqlite3_vtab_distinct() interface
that indicates that SQLite wants distinct results that are sorted.

FossilOrigin-Name: 135d8b97b01f9b5204f486f828c274c2d779c17723e79171ca61f738746adf8e

3 years agoUpdates a comment and an assert(). vtab-distinct-ordered
drh [Thu, 17 Mar 2022 18:03:08 +0000 (18:03 +0000)] 
Updates a comment and an assert().

FossilOrigin-Name: 0c5be14aac07222b9cd2404ae485b6587f8cb2899e776bc45f1f1117bdd7e9b7

3 years agoAnother fix for a corner-case in sqlite_offset() - this one having to
drh [Thu, 17 Mar 2022 11:23:13 +0000 (11:23 +0000)] 
Another fix for a corner-case in sqlite_offset() - this one having to
do with computed virtual columns in a WITHOUT ROWID table.

FossilOrigin-Name: 84ddd19bcec99f04b43b1a823477457758a2d93ea9beda43598e1234ea07776c

3 years agoAdd extra test cases.
dan [Wed, 16 Mar 2022 19:28:18 +0000 (19:28 +0000)] 
Add extra test cases.

FossilOrigin-Name: 0a922d141749cf3ef672f56449001e03f1a7e31822b66dcaf8550bb6e1b88cd3

3 years agoUpdate the sqlite3_vtab_distinct() documentation.
drh [Wed, 16 Mar 2022 14:51:35 +0000 (14:51 +0000)] 
Update the sqlite3_vtab_distinct() documentation.

FossilOrigin-Name: 88929d85e2ae81c51634ddb65ebec439958b63581016f9ccb4f5388715b3fe3f

3 years agoExperimental change to have sqlite3_vtab_distinct() return 3 to indicate that results...
dan [Wed, 16 Mar 2022 12:06:00 +0000 (12:06 +0000)] 
Experimental change to have sqlite3_vtab_distinct() return 3 to indicate that results should sorted and duplicates may be removed.

FossilOrigin-Name: 11f4508895c0a46d8623ca2f4f37b4f1b54b6d9022765f6124a9d42132f7d633

3 years agoMake CLI complain about incomplete input at EOF. Fix for regression reported at https...
larrybr [Tue, 15 Mar 2022 17:57:42 +0000 (17:57 +0000)] 
Make CLI complain about incomplete input at EOF. Fix for regression reported at https://sqlite.org/forum/forumpost/718f489a43be3197

FossilOrigin-Name: 72029cf7cdb266703cc8716102dbba8e6f2666e1f47409f42c39528795757b73

3 years agoCalling sqlite3_value_dup() on a pointer value results in an ordinary
drh [Mon, 14 Mar 2022 23:50:38 +0000 (23:50 +0000)] 
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

3 years agoFix an assert() statement in the covering index optimization for the corner
drh [Mon, 14 Mar 2022 22:58:04 +0000 (22:58 +0000)] 
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

3 years agoDisable trigger coding while running sqlite3_declare_vtab().
drh [Mon, 14 Mar 2022 20:31:57 +0000 (20:31 +0000)] 
Disable trigger coding while running sqlite3_declare_vtab().
dbsqlfuzz 97e1865771b4226f29e6e482411c1cae14133f50

FossilOrigin-Name: 387ab17b8a0a4b87903aab52abc7da79098b882aff2ab687a554d5794e9d183e

3 years agoForeign key constraint failures should return SQLITE_CONSTRAINT_FOREIGNKEY
drh [Mon, 14 Mar 2022 16:54:05 +0000 (16:54 +0000)] 
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

3 years agoAdd a comment linking a part of the UPDATE constraint checking code to
drh [Fri, 11 Mar 2022 15:42:05 +0000 (15:42 +0000)] 
Add a comment linking a part of the UPDATE constraint checking code to
one of the corresponding TH3 test cases.

FossilOrigin-Name: 0606e8e93edb5de4d154f377dbf91f15295d25ca9013c0f1612ae6d63a0139ea

3 years agoFix a harmless compiler warning.
drh [Fri, 11 Mar 2022 15:16:50 +0000 (15:16 +0000)] 
Fix a harmless compiler warning.

FossilOrigin-Name: 5d739aff96c47146dba72fd76fed62d4e43ded09b32246fdde13d5467f713135

3 years agoFix a harmless compiler warning and restore performance in the
drh [Fri, 11 Mar 2022 14:20:06 +0000 (14:20 +0000)] 
Fix a harmless compiler warning and restore performance in the
sqlite3BtreeIndexMoveto() last-page optimization.

FossilOrigin-Name: 8b032293b384c3728c27b0658ee634c028c0d231d067de8b747d2e9e4ae704a7

3 years agoFix a case in fts5 where a corrupt database could cause a crash.
dan [Fri, 11 Mar 2022 12:02:18 +0000 (12:02 +0000)] 
Fix a case in fts5 where a corrupt database could cause a crash.

FossilOrigin-Name: 5e95df261cce275adb5b2226e9584f4c389bb0d53c3b4feafd5a14be8d02ce63

3 years agoAnother corruption detection case in the sqlite3BtreeIndexMoveto()
drh [Thu, 10 Mar 2022 23:37:58 +0000 (23:37 +0000)] 
Another corruption detection case in the sqlite3BtreeIndexMoveto()
last page optimization.

FossilOrigin-Name: 531e6ad0389c6c820bb8c64db5049fb6b0bffd30bd394fd8ee7412959b1752e2

3 years agoIn the sqlite3BtreeIndexMoveto() last-page optimization, make sure to return
drh [Thu, 10 Mar 2022 22:54:32 +0000 (22:54 +0000)] 
In the sqlite3BtreeIndexMoveto() last-page optimization, make sure to return
SQLITE_CORRUPT if corruption is detected.

FossilOrigin-Name: 4ef19ba9b5cbda435c0bb9f2faddf8f7fac5d51399ff69bd049571c2ca3d9357

3 years agoStronger defenses against corrupt schemas in the ALTER TABLE logic.
drh [Thu, 10 Mar 2022 21:04:49 +0000 (21:04 +0000)] 
Stronger defenses against corrupt schemas in the ALTER TABLE logic.

FossilOrigin-Name: 13fbde28173332522a7ad307c1aad2b83c9aa1fe737583afa2b29f6da4de6370

3 years agoAmend sqlite3_column_*() doc table. (no code change)
larrybr [Thu, 10 Mar 2022 19:44:04 +0000 (19:44 +0000)] 
Amend sqlite3_column_*() doc table. (no code change)

FossilOrigin-Name: 1f473099776249f774a285fa117316636e00c3ff030ba0f22ed5bd05641c1bc9

3 years agoPrevent a NULL-pointer dereference when trying to parse a illegal
drh [Thu, 10 Mar 2022 16:26:00 +0000 (16:26 +0000)] 
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

3 years agoRefactor Window.pFunc into Window.pWFunc to disambiguate from other uses of
drh [Thu, 10 Mar 2022 16:01:14 +0000 (16:01 +0000)] 
Refactor Window.pFunc into Window.pWFunc to disambiguate from other uses of
the variable or field named "pFunc".

FossilOrigin-Name: d9475ebcde169272ad7b1d3a82b2326df55dafc68217bfecd9fcd1f2b89efbd9

3 years agoOnly run atof1.test on x86_64 machines.
drh [Thu, 10 Mar 2022 11:48:16 +0000 (11:48 +0000)] 
Only run atof1.test on x86_64 machines.

FossilOrigin-Name: 4173819cd285a1c133645eda27b9f6dc5a2247eaa0c834bdc60058ef3109b102

3 years agoMention that sqlite3_column_text16() returns have native endianness
larrybr [Thu, 10 Mar 2022 02:23:43 +0000 (02:23 +0000)] 
Mention that sqlite3_column_text16() returns have native endianness

FossilOrigin-Name: 25b7f88fcb2bb1908abde109c1167c462efbb156b4a8a8f94d36202bd93ea433

3 years agoCheck-in [642a0b4752743216] fixing sqlite_dbpage is not exactly correct.
drh [Thu, 10 Mar 2022 01:10:28 +0000 (01:10 +0000)] 
Check-in [642a0b4752743216] fixing sqlite_dbpage is not exactly correct.
This patch should fix it.

FossilOrigin-Name: 6ba36714ca5e5457bc424273129f2814b62b7fae38926aa6eeeeec81020d7f70

3 years agoFurther refinements to the sqlite_offset() fix from [6029514b08b88e3f].
drh [Wed, 9 Mar 2022 18:29:19 +0000 (18:29 +0000)] 
Further refinements to the sqlite_offset() fix from [6029514b08b88e3f].

FossilOrigin-Name: 6f838305e2c848a43b210bd1b7b962fb9e3c41de34de778675e6578fcd99f397

3 years agoFix the sqlite_dbpage virtual table so that it starts a write transaction
drh [Wed, 9 Mar 2022 14:22:28 +0000 (14:22 +0000)] 
Fix the sqlite_dbpage virtual table so that it starts a write transaction
on all attached schemas.

FossilOrigin-Name: 642a0b4752743216271e4f855a465515ef7f6a985f280251e18d67e3d5fb694b

3 years agoDo not use va_arg() as an l-value, because
drh [Wed, 9 Mar 2022 13:22:53 +0000 (13:22 +0000)] 
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

3 years agoImprove the defenses against bad pathnames input into the findCreateFileMode()
drh [Wed, 9 Mar 2022 12:20:40 +0000 (12:20 +0000)] 
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

3 years agoFix a minor typo in a comment.
drh [Tue, 8 Mar 2022 15:49:17 +0000 (15:49 +0000)] 
Fix a minor typo in a comment.

FossilOrigin-Name: cf61419f8816377f40ea032e1e3fb8b765ff7eb5b3a5ece8f7b59acffc5d3f05

3 years agoFix compiler warnings.
drh [Tue, 8 Mar 2022 13:59:46 +0000 (13:59 +0000)] 
Fix compiler warnings.

FossilOrigin-Name: 5e30c6ea707f9d381127e8b2bb59e0b39bc00997da2c14d32a0e302d0121203b

3 years agoDisable an assert in moveToRoot() when the database is corrupt.
drh [Mon, 7 Mar 2022 18:32:08 +0000 (18:32 +0000)] 
Disable an assert in moveToRoot() when the database is corrupt.
[forum:/forumpost/e9a176b7bd|Forum post e9a176b7bd].

FossilOrigin-Name: ae464a18d74bf44fc95bc335e75e6a57dc974f6d6a3d603133594039fb589af2

3 years agoIn the stay-on-last-page optimization for sqlite3BtreeIndexMoveto()
drh [Mon, 7 Mar 2022 17:19:40 +0000 (17:19 +0000)] 
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

3 years agoDo not allocate new Trigger objects in the parser following a syntax error,
drh [Mon, 7 Mar 2022 16:22:31 +0000 (16:22 +0000)] 
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

3 years agoFix the code generated for vector IN operator constraints on virtual tables
drh [Mon, 7 Mar 2022 14:51:29 +0000 (14:51 +0000)] 
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

3 years agoOptimizations to sqlite3BtreeIndexMoveto() avoid unnecessary comparisons if
drh [Mon, 7 Mar 2022 01:29:36 +0000 (01:29 +0000)] 
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

3 years agoDisentangle variable use in last checkin
larrybr [Mon, 7 Mar 2022 00:14:52 +0000 (00:14 +0000)] 
Disentangle variable use in last checkin

FossilOrigin-Name: 4c3a02600f10926da1f88ddbd457bb1486e6e02dee366b5cfc89e498a10daa6f

3 years agoFor CLI .import, revert to importing into temp or main when given table is found...
larrybr [Sun, 6 Mar 2022 23:41:21 +0000 (23:41 +0000)] 
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

3 years agoFix obsolete but harmless comments in btree. No changes to code.
drh [Sun, 6 Mar 2022 20:22:24 +0000 (20:22 +0000)] 
Fix obsolete but harmless comments in btree.  No changes to code.

FossilOrigin-Name: 4838b888e431f794b8a5ee65e797b3bf0616c03261de4e1fc9499287eb3e1265

3 years agoThe sqlite_offset() function should be non-deterministic.
drh [Sun, 6 Mar 2022 11:43:06 +0000 (11:43 +0000)] 
The sqlite_offset() function should be non-deterministic.
dbsqlfuzz 3df8230bb940870db87ffca2c0fc759c1e7fa356.

FossilOrigin-Name: e1a185e60afd32d3b25278dee42049920759ccd8fe709161007f5daa4a048693

3 years agoRemove a NEVER() associated with sqlite_offset()>
drh [Sat, 5 Mar 2022 23:52:05 +0000 (23:52 +0000)] 
Remove a NEVER() associated with sqlite_offset()>

FossilOrigin-Name: e29dffcdba6f68af5cb76ca250e06a42183d9db92b60a16b2337b0d43c68bf2e

3 years agoFix the 'localtime' modifier in date/time functions so that it preserves
drh [Sat, 5 Mar 2022 20:12:53 +0000 (20:12 +0000)] 
Fix the 'localtime' modifier in date/time functions so that it preserves
fractional seconds.
[forum:/forumpost/2ffbaa2c3fd7fb82|Forum post 2ffbaa2c3fd7fb82].

FossilOrigin-Name: 1c875b0764ab00e95c92f0ee329659e88041763e125c2891201d80f68c41f717

3 years agoFurther improvements to the sqlite_offset() function.
drh [Sat, 5 Mar 2022 19:36:29 +0000 (19:36 +0000)] 
Further improvements to the sqlite_offset() function.

FossilOrigin-Name: 4230e2f5e068f2151fa33be25bb06123d41273dbe497a5ebc7173f8d7f81d160

3 years agoFix the sqlite_offset() function so that it gives the correct answer even
drh [Sat, 5 Mar 2022 14:44:12 +0000 (14:44 +0000)] 
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

3 years agoUpdate obsolete text in the ICU README.txt file talking about SQLite's
drh [Sat, 5 Mar 2022 11:57:28 +0000 (11:57 +0000)] 
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

3 years agoDo try to evaluate the Bloom filter on a LEFT JOIN early, as doing so
drh [Fri, 4 Mar 2022 20:54:09 +0000 (20:54 +0000)] 
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

3 years agoWhen setting an sqlite3_value object to a pointer value, make sure any prior
drh [Fri, 4 Mar 2022 16:28:24 +0000 (16:28 +0000)] 
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

3 years agoRestore the ability to push-down OR subterms of the WHERE clause when
drh [Thu, 3 Mar 2022 19:40:21 +0000 (19:40 +0000)] 
Restore the ability to push-down OR subterms of the WHERE clause when
processing a multi-index OR.

FossilOrigin-Name: d71fb6fdc32d2fce73059b6ab86d7d7bbc812c637469755dd45b6794aadc3a80

3 years agoMake sure the xParseCell and xCellSize methods of the MemPage object are
drh [Thu, 3 Mar 2022 16:48:35 +0000 (16:48 +0000)] 
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

3 years agoFix for the problem identified in
drh [Thu, 3 Mar 2022 15:59:22 +0000 (15:59 +0000)] 
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

3 years agoAdd the new OP_BeginSubrtn opcode (which is really an alias for OP_Integer)
drh [Thu, 3 Mar 2022 15:00:44 +0000 (15:00 +0000)] 
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

3 years agoBloom filter pull-down optimization is incompatible with Skip-Scan.
drh [Wed, 2 Mar 2022 21:04:10 +0000 (21:04 +0000)] 
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

3 years agoFaster version of sqlite3VdbeMemRelease().
drh [Wed, 2 Mar 2022 17:50:59 +0000 (17:50 +0000)] 
Faster version of sqlite3VdbeMemRelease().

FossilOrigin-Name: 86c5fa2f301e4bdb538099f654b70b6ba0e214778cba2c53c53844e5d7ca129f

3 years agoReinstate the releaseMemArray() performance optimization of
drh [Wed, 2 Mar 2022 13:45:22 +0000 (13:45 +0000)] 
Reinstate the releaseMemArray() performance optimization of
[bb520293d8c11518] with corrections.

FossilOrigin-Name: 1291080d118c678072289a2e57a56b73657e9256ae47eafa7853716c8d47392f

3 years agoThe optimization at [ece326db50201937] is not quite right, so back it out
drh [Wed, 2 Mar 2022 11:39:11 +0000 (11:39 +0000)] 
The optimization at [ece326db50201937] is not quite right, so back it out
for now.

FossilOrigin-Name: b218a4b9fe44ffc5cb8d2a2491a5aad217d37b26ccc6b04caf8f28b71bcfe809

3 years agoFix a harmless compiler warning.
drh [Wed, 2 Mar 2022 01:02:16 +0000 (01:02 +0000)] 
Fix a harmless compiler warning.

FossilOrigin-Name: 6497997aa80419688890ed5dbbb7d6acc26bf3732305ff4a728cba1fe4d1626b

3 years agoThe performance optimizations at [bb520293d8c11518] is not quite right,
drh [Wed, 2 Mar 2022 00:50:06 +0000 (00:50 +0000)] 
The performance optimizations at [bb520293d8c11518] is not quite right,
so it has to be backed out.

FossilOrigin-Name: 15f73b121cacf77ada02bfe434f9caa1175ac482d007156cfb0864e4221490d1

3 years agoThe MemPage.aDataEnd field should point to the end of the data buffer for
drh [Tue, 1 Mar 2022 20:15:04 +0000 (20:15 +0000)] 
The MemPage.aDataEnd field should point to the end of the data buffer for
the page, not just the end of the usable portion of that buffer.  The purpose
aDataEnd is to detect cells that overflow the page, and that won't work on a
page with reserved bytes and a cell that starts in the reserved region, unless
the boundary is at the very end of the page. Chromium issue 1276294.

FossilOrigin-Name: f839c0bc8388a31f6db5081906b66b9e129855ba27a13cf13bd995b083f7386e

3 years agoFix a minor typo in a comment.
drh [Tue, 1 Mar 2022 19:19:20 +0000 (19:19 +0000)] 
Fix a minor typo in a comment.

FossilOrigin-Name: 86ba06aa4c55d3aefe030b19b2b5c08baf46bbb2218b04ac1228ab76682a929b

3 years agoFix two assert() statements in btree.c which were not true in the case of
drh [Tue, 1 Mar 2022 16:22:54 +0000 (16:22 +0000)] 
Fix two assert() statements in btree.c which were not true in the case of
a corrupt database file.
[forum:/forumpost/14819f2063|Forum post 14819f2063].

FossilOrigin-Name: 3b36ed79d82fae47a08a7d27f4fcefb7978fdf0e7f8c0f4a82f59501f201b32b

3 years agoFix slightly-incorrect assert() statements.
drh [Tue, 1 Mar 2022 15:48:16 +0000 (15:48 +0000)] 
Fix slightly-incorrect assert() statements.
[forum:/forumpost/f1e83b77b5ff37db|Forum post f1e83b77b5ff37db]

FossilOrigin-Name: 3c9f5c9defd7d36684132ae4ade9db2e2148dad4bd91bfe9374620ecafc35348

3 years agoIncrease the max_page_count on ROLLBACK, if necessary, so that it is sufficient
drh [Tue, 1 Mar 2022 14:13:32 +0000 (14:13 +0000)] 
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

3 years agoFix the Xfer-optimization on the INSERT statement so that it is omitted if
drh [Mon, 28 Feb 2022 16:44:58 +0000 (16:44 +0000)] 
Fix the Xfer-optimization on the INSERT statement so that it is omitted if
there is a RETURNING clause, since that optimization is not able to deal
with RETURNING.  See [forum:/forumpost/595e132f71|forum thread 595e132f71]
for details.

FossilOrigin-Name: 1d3760a517b8bd2a6be82d2d5788945f49397cdc539fe28fd23e2c0c62a1dbe2

3 years agoReorganize the bits in Mem.flags. Free up one bit for reuse.
drh [Mon, 28 Feb 2022 14:26:33 +0000 (14:26 +0000)] 
Reorganize the bits in Mem.flags.  Free up one bit for reuse.

FossilOrigin-Name: fe454291d959c299d6608dfc165c9e05fb53e431b0fc7aed1cb4a557cd61d8ab

3 years agoExpand the comment on the definition of the Mem object to better explain the
drh [Mon, 28 Feb 2022 13:38:28 +0000 (13:38 +0000)] 
Expand the comment on the definition of the Mem object to better explain the
meanings of the various flag bits.

FossilOrigin-Name: f2f0426035d4e0334be000a3eb62bbd7d61fdab7c2ef9ba13cfdf6482396dd13

3 years agoPerformance optimization in initMemArray() saves about 750K cycles with only
drh [Mon, 28 Feb 2022 12:16:51 +0000 (12:16 +0000)] 
Performance optimization in initMemArray() saves about 750K cycles with only
a 4-byte increase in code size.

FossilOrigin-Name: c3e9cd5e7430be0653a96a2097a695447549980e08cc8bd8d8097a50c954908e

3 years agoThe performance increase in the previous check-in of this branch was due to optimize-init-mem
drh [Mon, 28 Feb 2022 12:08:09 +0000 (12:08 +0000)] 
The performance increase in the previous check-in of this branch was due to
the revised loop in initMemArray() and reordering fields of Mem - not the
call the memcpy().  Changing the code to avoid memcpy() results in an even
better gain, and code that is far less dodgy.

FossilOrigin-Name: d74aa979530d4236f5900d2ef998b27065d352d7c18bcd822e5c8f1041a1a81c

3 years agoAn optimization to initMemArray() saves almost 500K cycles. But it seems a
drh [Mon, 28 Feb 2022 03:25:13 +0000 (03:25 +0000)] 
An optimization to initMemArray() saves almost 500K cycles.  But it seems a
little dodgy.  I want to think about this more before merging to trunk.
Perhaps there is a cleaner way to accomplish the same.

FossilOrigin-Name: 7fefd8676110a53e6c98a697e2dbf820740fe602a1e83b6caa8d099c41a15d80

3 years agoAvoid unnecessary deinitialization of the Mem.flags field.
drh [Mon, 28 Feb 2022 02:35:48 +0000 (02:35 +0000)] 
Avoid unnecessary deinitialization of the Mem.flags field.

FossilOrigin-Name: bb520293d8c11518ba153b986662f081ebfd781d38eb624c509605fa9148f6e9

3 years agoCache values of UnpackedRecord.aMem[0] into new fields of UnpackedRecord.
drh [Sun, 27 Feb 2022 21:10:49 +0000 (21:10 +0000)] 
Cache values of UnpackedRecord.aMem[0] into new fields of UnpackedRecord.
This avoids extra indirections and saves about 750K cycles.

FossilOrigin-Name: 7cf2d1f0396362aae7b93da75c2036d52ba86acba1cc90abca560bcf0314a22f

3 years agoBypass a single branch in vdbeRecordCompareString() in the common case, for
drh [Sun, 27 Feb 2022 18:54:33 +0000 (18:54 +0000)] 
Bypass a single branch in vdbeRecordCompareString() in the common case, for
a performance increase of over 600K CPU cycles.

FossilOrigin-Name: 36f0f07e505dfb38c61d3b4d5b947013c8793e6796fe690e53864479b9276abb

3 years agoRemove an unnecessary local variable for a small performance increase and size
drh [Sat, 26 Feb 2022 23:01:25 +0000 (23:01 +0000)] 
Remove an unnecessary local variable for a small performance increase and size
reduction.

FossilOrigin-Name: 9bda611f0d182a62ac1b68610313143c2e28868c16c7d4362a8f5945c27dd88e

3 years agoAllow the OP_Column opcode to read rows that are larger than
drh [Sat, 26 Feb 2022 14:39:08 +0000 (14:39 +0000)] 
Allow the OP_Column opcode to read rows that are larger than
SQLITE_LIMIT_LENGTH as long as the specific field being read out is
less than or equal to SQLITE_LIMIT_LENGTH.

FossilOrigin-Name: 1bf4848995ab094ad84ef4aa1563bce641d5acf7335fb4630c892b16cf7d7edd

3 years agoRevise the initialization processing for OP_Column to make it about
drh [Fri, 25 Feb 2022 20:11:59 +0000 (20:11 +0000)] 
Revise the initialization processing for OP_Column to make it about
1.8 million cycles faster.

FossilOrigin-Name: 3b7259ebd5b9b1f75577521c4d0d96f5503d302a513b20a0b17dbe8c3823dd33

3 years agoFix the OP_NullRow documentation so that it accurately describes what it
drh [Fri, 25 Feb 2022 18:51:09 +0000 (18:51 +0000)] 
Fix the OP_NullRow documentation so that it accurately describes what it
actually does for a pseudo-cursor.

FossilOrigin-Name: 4e269902094e8f9d852e5fc852e473167048fdeb9034f1fb1436f6df205de926

3 years agoImproved comment on the codeDeferredSeek() routine. No code changes.
drh [Fri, 25 Feb 2022 13:29:56 +0000 (13:29 +0000)] 
Improved comment on the codeDeferredSeek() routine. No code changes.

FossilOrigin-Name: 54f49f65ac943263a1622b1efe519c8a61f30f23694fd4fec89ad2bf0e17b473

3 years agoFix unimportant typos in comment text.
drh [Fri, 25 Feb 2022 11:30:29 +0000 (11:30 +0000)] 
Fix unimportant typos in comment text.

FossilOrigin-Name: 393460132994d6ca133e52af57374e43a2795a9e7fc7781bd9dea752a2b52c6a

3 years agoInvoking SQLITE_TESTCTRL_INTERNAL_FUNCTIONS causes the flags field of the
drh [Fri, 25 Feb 2022 01:23:17 +0000 (01:23 +0000)] 
Invoking SQLITE_TESTCTRL_INTERNAL_FUNCTIONS causes the flags field of the
PRAGMA function_list to show all bits, including internal-use-only bits,
rather than just the bits that are part of the API.

FossilOrigin-Name: ad1be34828726bfef0dbc0ce16090400cf3530e7b5077849af96774d7428387b

3 years agoRemove unused P4 types on the Opcode object. Saves a few bytes of code
drh [Fri, 25 Feb 2022 01:10:57 +0000 (01:10 +0000)] 
Remove unused P4 types on the Opcode object.  Saves a few bytes of code
space and simplifies the code.

FossilOrigin-Name: aca538435939e6146f9a42e72e3a65030bbc5f646a0bbc7684e43688a0339888

3 years agoChange the OP_Next and OP_Prev opcodes so that they invoke
drh [Thu, 24 Feb 2022 14:44:23 +0000 (14:44 +0000)] 
Change the OP_Next and OP_Prev opcodes so that they invoke
sqlite3BtreeNext() and sqlite3BtreePrevious() directly rather than through
a function pointer, for improved performance and a decrease in code size.

FossilOrigin-Name: 9d13cbbef3cf64f281d3e100f23f1b2ed6e8d65920c7517a84e1e4f964ceff2e

3 years agoSpell fix, no code change
larrybr [Thu, 24 Feb 2022 11:09:08 +0000 (11:09 +0000)] 
Spell fix, no code change

FossilOrigin-Name: f2597fae3c2b8f77f98a3ba9420b309f649b4008f9530d3cfaeeba1e2bf5d8a3

3 years agoFix an assert() so that it is still valid following OOM with the latest
drh [Thu, 24 Feb 2022 01:41:14 +0000 (01:41 +0000)] 
Fix an assert() so that it is still valid following OOM with the latest
enhancements.

FossilOrigin-Name: ecf832f71fbaee36ee10f6da5bde19a8af9f90adbba06e8c5706d18b768bae1f

3 years agoUpdate the version number of version 3.39.0 for the next development cycle.
drh [Thu, 24 Feb 2022 01:08:53 +0000 (01:08 +0000)] 
Update the version number of version 3.39.0 for the next development cycle.

FossilOrigin-Name: 9542e9bebbd25b20228fa2366b76d55845a40f12fdc4bbd077d1cb48e32b8cf2

3 years agoAdd a new subclass for MemPage.xCellSize specifically for the case of a leaf
drh [Wed, 23 Feb 2022 22:56:10 +0000 (22:56 +0000)] 
Add a new subclass for MemPage.xCellSize specifically for the case of a leaf
page in a B+Tree, that is optimized for that cases.  This gains a half million
cycles or more at the cost of less than 200 bytes of code space.

FossilOrigin-Name: 7ad829224adbec5d74ff9e5ab040eb2ad3e17fe45da7a2cf0cca770a0731401a

3 years agoOptimize calls to get2byte() in btree.c for almost a one-million cycle
drh [Wed, 23 Feb 2022 18:23:15 +0000 (18:23 +0000)] 
Optimize calls to get2byte() in btree.c for almost a one-million cycle
performance gain and a few bytes less code.

FossilOrigin-Name: 41061f29969dc546c2702f7f412127070a4dd54593827692df93a83c939dfb61

3 years agoDefer the check for error check Pgno zero until after the page fetch misses,
drh [Wed, 23 Feb 2022 17:16:30 +0000 (17:16 +0000)] 
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

3 years agoStore the page number for the PENDING_BYTE page in the Pager object, rather
drh [Wed, 23 Feb 2022 17:00:44 +0000 (17:00 +0000)] 
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

3 years agoFor the "PRAGMA database_list" statement, do not check to see if the schema
drh [Tue, 22 Feb 2022 20:29:31 +0000 (20:29 +0000)] 
For the "PRAGMA database_list" statement, do not check to see if the schema
is up-to-date and do not try to reload the schema.

FossilOrigin-Name: 710de6a2137c872812effa43ea888aa77d339362ca0b6c8990d4426c8fb20689

3 years agoVersion 3.38.0 version-3.38.0
drh [Tue, 22 Feb 2022 18:58:40 +0000 (18:58 +0000)] 
Version 3.38.0

FossilOrigin-Name: 40fa792d359f84c3b9e9d6623743e1a59826274e221df1bde8f47086968a1bab

3 years agoFix an undersized memory allocation in the test harness for RTREE. This
drh [Tue, 22 Feb 2022 15:47:55 +0000 (15:47 +0000)] 
Fix an undersized memory allocation in the test harness for RTREE.  This
error was in test logic only, not in the SQLite library itself.
[forum:/forumpost/35470a0a72a005e1|forum post 35470a0a72a005e1]

FossilOrigin-Name: 7e3c9594390ac8defaf9825e14b4c19ef8c123b747971dd3d4df16110f443d3b