]> git.ipfire.org Git - thirdparty/sqlite.git/log
thirdparty/sqlite.git
3 years agoSplit out the RUN state into separate READY and RUN states. vdbe-state-refactor
drh [Thu, 31 Mar 2022 21:15:09 +0000 (21:15 +0000)] 
Split out the RUN state into separate READY and RUN states.

FossilOrigin-Name: d698826b08b88e227eb83f84b3cdb19f17306b532eccfa162090abccdf3c63d8

3 years agoRename Vdbe.iVdbeMagic to eVdbeState. Remove unnecessary states. This is
drh [Thu, 31 Mar 2022 20:04:49 +0000 (20:04 +0000)] 
Rename Vdbe.iVdbeMagic to eVdbeState.  Remove unnecessary states.  This is
a preliminary step toward splitting RUN_STATE out into several other states.

FossilOrigin-Name: ff91191d232305d44ae6c0fbca2542a749422dc716fa1fd5d54f58c7d6052c14

3 years agoFix harmless compiler warnings.
drh [Thu, 31 Mar 2022 16:09:13 +0000 (16:09 +0000)] 
Fix harmless compiler warnings.

FossilOrigin-Name: b916087aacba53530d2bd19eef2a4fd7a253bf7fa87b49e0df17f7987d7164ae

3 years agoRefinement to [3f9887d4a58cbfdb]: The SQLITE_CONSTRAINT error should only
drh [Thu, 31 Mar 2022 11:12:56 +0000 (11:12 +0000)] 
Refinement to [3f9887d4a58cbfdb]:  The SQLITE_CONSTRAINT error should only
be returned if the prepared statement came from sqlite3_prepare_v2().  The
legacy sqlite3_prepare() is documented to return only SQLITE_ERROR.

FossilOrigin-Name: f2d9262e4427ab37ba26c004fc7a4790c86c1856d695a6b4ec3e72732ea54c09

3 years agoFaster and slightly smaller implementation of sqlite3Step().
drh [Wed, 30 Mar 2022 17:56:27 +0000 (17:56 +0000)] 
Faster and slightly smaller implementation of sqlite3Step().

FossilOrigin-Name: c6901a8c78838228f8135c9346b214e638b72086fd85367b9ff482273e62ece6

3 years agoSmall size reduction and performance increase in sqlite3FinishCoding().
drh [Wed, 30 Mar 2022 17:36:40 +0000 (17:36 +0000)] 
Small size reduction and performance increase in sqlite3FinishCoding().

FossilOrigin-Name: 9248ce50f57fb9c4ba67949fdf9c9567c3e626cd9dd1b41b71c602d29c77c43e

3 years agoIn setResultStrOrError(), if the input string pointer is NULL and hence the
drh [Tue, 29 Mar 2022 22:57:00 +0000 (22:57 +0000)] 
In setResultStrOrError(), if the input string pointer is NULL and hence the
value gets set to an SQL NULL, then the Mem.enc field is uninitialized.  So
do not read it.  This is a harmless OSSFuzz/ASAN found problem.

FossilOrigin-Name: 47d0b1c4cfc3d2d8f57a02079276bb70a205ffd0f18007dd39c92f813d4c87f5

3 years agoEnsure that sqlite3VdbeMemSetStr() always leaves the value in a consistent
drh [Tue, 29 Mar 2022 20:50:20 +0000 (20:50 +0000)] 
Ensure that sqlite3VdbeMemSetStr() always leaves the value in a consistent
state even if there is an error.

FossilOrigin-Name: c86ab289ec31ce9ae0abaf103a829b8d1e5ed632f493456f1f40607aeb91b41c

3 years agoReverse the order of two tests to stop a harmless initialized value
drh [Tue, 29 Mar 2022 19:19:23 +0000 (19:19 +0000)] 
Reverse the order of two tests to stop a harmless initialized value
warning from MSAN - reported by OSSFuzz.

FossilOrigin-Name: 800b8fdad73b67105e416b4b5c6a5c5ded7d6a43b4eacd6b67d690cab7584b0b

3 years agoAvoid unnecessary calls to balance() from sqlite3BtreeDelete().
drh [Tue, 29 Mar 2022 13:16:32 +0000 (13:16 +0000)] 
Avoid unnecessary calls to balance() from sqlite3BtreeDelete().

FossilOrigin-Name: d0966d1bdd474e27cb048884d340184f0e81a4fab65eb6b74682b20630caddf8

3 years agoFix the sqlite3_result_xxxxx() routines so that they all check for and
drh [Tue, 29 Mar 2022 01:43:09 +0000 (01:43 +0000)] 
Fix the sqlite3_result_xxxxx() routines so that they all check for and
perform any necessary text encoding conversions and check for oversize
strings and BLOBs.  Thus those checks can be done where they are most
efficient and avoided in cases like OP_Function where they are more
expensive.

FossilOrigin-Name: d50b162b2f2e320af0889b931351f9443580465a933f6657fa98f437b6579277

3 years agoFurther size and performance optimizations for sqlite3VdbeMemSetStr().
drh [Mon, 28 Mar 2022 18:34:40 +0000 (18:34 +0000)] 
Further size and performance optimizations for sqlite3VdbeMemSetStr().

FossilOrigin-Name: 310a3e102d8eedf92ee63ffffb48621abfb1e2736b96bd2a676d63cca0f40598

3 years agoSlightly smaller and faster sqlite3VdbeMemSetStr().
drh [Mon, 28 Mar 2022 17:34:46 +0000 (17:34 +0000)] 
Slightly smaller and faster sqlite3VdbeMemSetStr().

FossilOrigin-Name: 06928e745c7bcb26ec46a17989f30efe3536fd48a74c8a1cd423cc9ff6feccb5

3 years agoPerformance increase in the loop that frees an opcode array.
drh [Mon, 28 Mar 2022 15:06:36 +0000 (15:06 +0000)] 
Performance increase in the loop that frees an opcode array.

FossilOrigin-Name: 4ccebb86aae178dbce905d782f04d98211f8fce9aacd71c12b8694c92a4f5c40

3 years agoAnother small performance gain by using sqlite3DbFreeNN().
drh [Mon, 28 Mar 2022 14:56:47 +0000 (14:56 +0000)] 
Another small performance gain by using sqlite3DbFreeNN().

FossilOrigin-Name: daa924af987253345bdb1c71b13378681bd252521e94d01f5d4629601232c352

3 years agoUse sqlite3DbFreeNN() instead of sqlite3DbFree() in a few hot spots for
drh [Mon, 28 Mar 2022 14:18:03 +0000 (14:18 +0000)] 
Use sqlite3DbFreeNN() instead of sqlite3DbFree() in a few hot spots for
better performance.

FossilOrigin-Name: b12de0ecc78a4f654c8e7b2b17cc2201688808a4f516908e9563a216677e655c

3 years agoPerformance optimization in the memsys5 memory allocator.
drh [Mon, 28 Mar 2022 13:22:54 +0000 (13:22 +0000)] 
Performance optimization in the memsys5 memory allocator.

FossilOrigin-Name: 949133231f8f751aa86518d0d3f6f03d7827fec085bfef3929fa3d57369d0216

3 years agoFix the Bloom-filter optimization so that it does not use IS NULL or
drh [Fri, 25 Mar 2022 01:23:37 +0000 (01:23 +0000)] 
Fix the Bloom-filter optimization so that it does not use IS NULL or
IS NOT NULL constraints from the WHERE clause when operating on a LEFT JOIN.
[forum:/forumpost/031e262a89b6a9d2|Forum thread 031e262a89b6a9d2].

FossilOrigin-Name: 1a6328f2a5b4973094e5f85787145d652119822c86ec01a61f3f985c9d2903f2

3 years agoThe "PRAGMA writable_schema=ON" flag should not allow OOM errors to pass
drh [Thu, 24 Mar 2022 14:01:55 +0000 (14:01 +0000)] 
The "PRAGMA writable_schema=ON" flag should not allow OOM errors to pass
while parsing the schema.
dbsqlfuzz 9cc49e1a53e1cef8e3a1496a88c683aa20483163.

FossilOrigin-Name: a7abb725c7c783331e73837597917e25e5ff692aac8ec97a0a8c0e30db62d68b

3 years agoUse trickery to code the UTF-8 BOM for the --bom option on .output, .once,
drh [Wed, 23 Mar 2022 10:04:52 +0000 (10:04 +0000)] 
Use trickery to code the UTF-8 BOM for the --bom option on .output, .once,
and .excel in the CLI, to work around a warning in some Microsoft compilers.
[https://fossil-scm.org/forum/forumpost/bd0844268f0fab71|Fossil forum post bd0844268f0fab71].

FossilOrigin-Name: 43143ad131f17734fd2eff849e0a1bc2e26daf6a28c7e07d697d38732e6af5fc

3 years agoEnsure that database corruption does not cause the cursor passed into
drh [Tue, 22 Mar 2022 23:33:20 +0000 (23:33 +0000)] 
Ensure that database corruption does not cause the cursor passed into
sqlite3BtreeDelete() to be invalid.
dbsqlfuzz 209bf3de9ee11ae440848ab9bc9c13858f9be2e4.

FossilOrigin-Name: a85126f96614c53b030c6e6c43ff239eae458048597a10e9a0361fcec8628ecf

3 years agoHarden the xShmLock method of both the unix and Windows VFSes so that they
drh [Tue, 22 Mar 2022 19:41:55 +0000 (19:41 +0000)] 
Harden the xShmLock method of both the unix and Windows VFSes so that they
are robust against being invoked when the SHM file is not open.

FossilOrigin-Name: 67d8b434f628d44c4a90ce8ff5ab2e381f500bb42bdbfab9a17d21925a2ec6cd

3 years agoMake the sqlite3_serialize() and sqlite3_deserialize() interfaces accessible
drh [Tue, 22 Mar 2022 11:22:55 +0000 (11:22 +0000)] 
Make the sqlite3_serialize() and sqlite3_deserialize() interfaces accessible
to loadable extensions.

FossilOrigin-Name: 81f8746bc65828fb91e170393f22f1f4e9c587a8938e8c11b72315fcd6131403

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