]> git.ipfire.org Git - thirdparty/sqlite.git/log
thirdparty/sqlite.git
3 years agoTokenizer and grammar rules sufficient for the MERGE command. merge-statement
drh [Fri, 8 Apr 2022 10:35:32 +0000 (10:35 +0000)] 
Tokenizer and grammar rules sufficient for the MERGE command.

FossilOrigin-Name: 2deee326e850e829a73535930aecc5d512eb87790862c16c0993e92766d5c779

3 years agoFix two unreachable branches introduced by the recent
drh [Thu, 7 Apr 2022 20:45:38 +0000 (20:45 +0000)] 
Fix two unreachable branches introduced by the recent
sqlite3TriggersExist() optimization.

FossilOrigin-Name: 1b5475d212cf9de0bff69eee8c607b4fcd8e04bf4df72171429e7609c4153951

3 years agoEnhance the EXPLAIN output formatting in the CLI so that the subroutine that
drh [Thu, 7 Apr 2022 19:06:31 +0000 (19:06 +0000)] 
Enhance the EXPLAIN output formatting in the CLI so that the subroutine that
implements the loop body for the multi-index OR optimization is indented.

FossilOrigin-Name: c2965fea9df7076b235d3eadaf84f0a36242476d0329030b0e57557b66e2540c

3 years agoThe ".testctrl optimizations 0x400000" command disables the generation of
drh [Thu, 7 Apr 2022 18:17:56 +0000 (18:17 +0000)] 
The ".testctrl optimizations 0x400000" command disables the generation of
OP_ReleaseReg opcodes.  OP_ReleaseReg opcodes are usually only generated for
SQLITE_DEBUG builds and are used to verify that registers are descoped
propertly.  But they can get in the way of code understanding when studying
bytecode dumps.  So this new optimization setting is provided to
temporarily turn OP_ReleaseReg opcodes off.

FossilOrigin-Name: fa5276725f246cef9d58b27c1e617ee3f873f7a9b88284a4e8fc453ebda338bc

3 years agoFix the parsing of C-style comments in Lemon, as reported by
drh [Thu, 7 Apr 2022 14:13:32 +0000 (14:13 +0000)] 
Fix the parsing of C-style comments in Lemon, as reported by
[forum:/forumpost/b6edc69548|forum post b6edc69548].  This has no affect
on SQLite itself.

FossilOrigin-Name: 201569e09b000919ccb463bd581fb2ecd5320e7f584fdb1bc2aaba111061d5c3

3 years agoOptimization to sqlite3TriggersExist() saves over 700K CPU cycles.
drh [Thu, 7 Apr 2022 14:03:07 +0000 (14:03 +0000)] 
Optimization to sqlite3TriggersExist() saves over 700K CPU cycles.

FossilOrigin-Name: 5043a3507e0781878e0e1bea5095a33273958820baead4af8fc2929e9d7c07ee

3 years agoAvoid compiler warnings about the new sqlite3Show() debugging routines
drh [Thu, 7 Apr 2022 13:48:34 +0000 (13:48 +0000)] 
Avoid compiler warnings about the new sqlite3Show() debugging routines
begin "defined but not used".

FossilOrigin-Name: 47ddc26974fbad8233c953d435e79d4f5dd5e09fbd684ea5f4ad32f4cae6cae6

3 years agoOmit an unnecessary initialization in tokenExpr().
drh [Thu, 7 Apr 2022 12:10:00 +0000 (12:10 +0000)] 
Omit an unnecessary initialization in tokenExpr().

FossilOrigin-Name: 8f6ae686019c61a03fe70eb78d2b529b1cf126215b45513a97cfdf7086f82f54

3 years agoFix harmless compiler warnings.
drh [Thu, 7 Apr 2022 10:11:35 +0000 (10:11 +0000)] 
Fix harmless compiler warnings.

FossilOrigin-Name: 61095b5bcb5c30d29f03efa5b4809e3a0b780ed57e35227c292aab9dd1cfe3f6

3 years agoImproved technique for parsing the ON and USING clauses of a join is faster
drh [Thu, 7 Apr 2022 01:11:13 +0000 (01:11 +0000)] 
Improved technique for parsing the ON and USING clauses of a join is faster
and uses less memory.

FossilOrigin-Name: 158156a3e3d50042cafc75dea3aaaa68b1f2efb9c3d178518ea6e68e32e0d21c

3 years agoFaster parsing of the FROM clause in joins for the common case where there
drh [Wed, 6 Apr 2022 19:46:20 +0000 (19:46 +0000)] 
Faster parsing of the FROM clause in joins for the common case where there
is no INDEXED BY clause.

FossilOrigin-Name: 848b7a0ea99ddc52091b78313f018c07d00a0e28aa6da8c1cae709c1d03468fe

3 years agoImprovements to the display of AST for DML statements.
drh [Wed, 6 Apr 2022 18:30:17 +0000 (18:30 +0000)] 
Improvements to the display of AST for DML statements.

FossilOrigin-Name: 84c239a071cfaf8af107646f01ef269e2915fd2384e95927d484f2e408ba6bbf

3 years agoAttempt to show triggers in the TreeView output from DELETE, INSERT, and
drh [Wed, 6 Apr 2022 15:41:53 +0000 (15:41 +0000)] 
Attempt to show triggers in the TreeView output from DELETE, INSERT, and
UPDATE statements.

FossilOrigin-Name: b0939d6f4d94b45dce53ace6295508a67d574cc72bd6977623bf77065b3c4e64

3 years agoCorrections and updates to the header comment describing the
drh [Wed, 6 Apr 2022 12:54:41 +0000 (12:54 +0000)] 
Corrections and updates to the header comment describing the
TriggerStep object.  No changes to code.

FossilOrigin-Name: abb34c0830a49d4f4e277ddd17e710529e87cba7061f3546079dbba2f82b020e

3 years agoAdd the sqlite3Show() family of debugging interfaces under SQLITE_DEBUG.
drh [Wed, 6 Apr 2022 12:25:04 +0000 (12:25 +0000)] 
Add the sqlite3Show() family of debugging interfaces under SQLITE_DEBUG.
No changes to deliverable builds.  Rename SQLITE_ENABLE_SELECTTRACE to
SQLITE_ENABLE_TREETRACE in ctime.c.

FossilOrigin-Name: bc33168cf1f48caf848c2dc5c3ae15e4efff8c0378f944eb5398a245139a2b35

3 years agoRename debugging defines and variables from SELECTTRACE to TREETRACE (and
drh [Wed, 6 Apr 2022 11:08:38 +0000 (11:08 +0000)] 
Rename debugging defines and variables from SELECTTRACE to TREETRACE (and
similar) since the functionality has how expanded to include data structures
beyond SELECT statements.  Should not affect deliverable builds.

FossilOrigin-Name: 393fa32e188a017f431372b54037cb31e885030542f00d0bfd59da9d9db5c014

3 years agoAdd additional tree display routines for DELETE and UPDATE. No changes
drh [Wed, 6 Apr 2022 10:37:44 +0000 (10:37 +0000)] 
Add additional tree display routines for DELETE and UPDATE.  No changes
to deliverable code.

FossilOrigin-Name: fbd288ff3d4ea47cd324b5952e7754a465901844f2d950f0860d4488d5b6eb9f

3 years agoAdd new diagnostic "sqlite3TreeView" routines for IdList, Upsert, and for
drh [Wed, 6 Apr 2022 00:29:21 +0000 (00:29 +0000)] 
Add new diagnostic "sqlite3TreeView" routines for IdList, Upsert, and for
INSERT statements.  This is all debugging code.  There are no changes to
release builds.

FossilOrigin-Name: f3084122039bcb30c8617f5f432009a49be8b488235850a1f10ef862c91560b2

3 years agoSmall performance and size improvement to OP_Found.
drh [Mon, 4 Apr 2022 20:20:22 +0000 (20:20 +0000)] 
Small performance and size improvement to OP_Found.

FossilOrigin-Name: 81587a18b7c0516628453000172a0c58e74ee173c15f655d035799d84d4e2d81

3 years agoTag an always-taken branch using ALWAYS().
drh [Mon, 4 Apr 2022 19:58:55 +0000 (19:58 +0000)] 
Tag an always-taken branch using ALWAYS().

FossilOrigin-Name: ad8bc3d7443ff57ce5a8756428e717ac42ec0295191a9b4d7ae44846d8fa03a2

3 years agoOptimizations to the OP_Found opcode save about 600K cycles in speedtest1.
drh [Mon, 4 Apr 2022 19:43:57 +0000 (19:43 +0000)] 
Optimizations to the OP_Found opcode save about 600K cycles in speedtest1.

FossilOrigin-Name: 5c3357ad62843fe982b9c2d31dbf02018f2948ceab2c85dac917cd9ce1e97dd6

3 years agoUse unpacked keys for OP_Found in foreign key processing.
drh [Mon, 4 Apr 2022 18:17:59 +0000 (18:17 +0000)] 
Use unpacked keys for OP_Found in foreign key processing.

FossilOrigin-Name: 328dc76657eb5317f0201859d2b3abe6918103b894f7beaed0aca3058a9f2b64

3 years agoWhen constructing the JSON Path for the "fullpath" column of the
drh [Mon, 4 Apr 2022 15:15:45 +0000 (15:15 +0000)] 
When constructing the JSON Path for the "fullpath" column of the
json_tree() and json_each() table-valued functions, be sure to quote
object labels where necessary.

FossilOrigin-Name: 0fbbe7881cadf0b3c211653c7a0797e0a90c7c24da78ecc8a27140c05f89f2ed

3 years agoFix the JSON Path parser so that it will accept zero-length object labels.
drh [Mon, 4 Apr 2022 14:24:14 +0000 (14:24 +0000)] 
Fix the JSON Path parser so that it will accept zero-length object labels.
[forum/forumpost/c082aeab43|Forum thread c082aeab43].

FossilOrigin-Name: 84fe95d2a5b4d232d657e3b8110027a698a9bcd597f205cc535cfa97bc299f21

3 years agoPerformance optimization and stronger assert()s in the comparison opcodes.
drh [Mon, 4 Apr 2022 11:38:49 +0000 (11:38 +0000)] 
Performance optimization and stronger assert()s in the comparison opcodes.

FossilOrigin-Name: e0305e640b9078c7eed9ab0bcc14f4515b54e7cd9ade3306bc2d1660f05b2725

3 years agoOnly invoke sqlite3VdbeClearObject() from a single location, so that the
drh [Mon, 4 Apr 2022 01:12:11 +0000 (01:12 +0000)] 
Only invoke sqlite3VdbeClearObject() from a single location, so that the
compiler is more likely to in-line the code.  Performance increase and
size reduction.

FossilOrigin-Name: c6947a96e61f71aa61ca3d70d9e2612d784ab04d60fa88852b03cfce86b1bf2b

3 years agoPerformance optimization in the sqlite3VdbeHalt() routine.
drh [Sun, 3 Apr 2022 22:35:13 +0000 (22:35 +0000)] 
Performance optimization in the sqlite3VdbeHalt() routine.

FossilOrigin-Name: 9564d72a0820dbcb38f905fcd42ed4c858ea8fb5f648b189ceb65380a14a785b

3 years agoPerformance optimization and size reduction in the OP_Halt opcode.
drh [Sun, 3 Apr 2022 20:39:48 +0000 (20:39 +0000)] 
Performance optimization and size reduction in the OP_Halt opcode.

FossilOrigin-Name: 21948e6e1ccd2ce128742415d21759604ecb8902226ec4707dbd75585450f208

3 years agoOmit the Vdbe.runOnlyOnce flag (simplifying the prepared statement
drh [Sun, 3 Apr 2022 19:13:40 +0000 (19:13 +0000)] 
Omit the Vdbe.runOnlyOnce flag (simplifying the prepared statement
implementation) and accomplish the same result by adding an "OP_Expire 1 1"
opcode to prepared statements that would normally have runOnlyOnce set.

FossilOrigin-Name: 6e20e1c46d17ac6aba21e02b57649af51cfa415d83d0c001b30677d2fd1f1dc1

3 years agoPerformance optimization and slight size reduction in the OP_Transaction
drh [Sun, 3 Apr 2022 10:42:06 +0000 (10:42 +0000)] 
Performance optimization and slight size reduction in the OP_Transaction
opcode.

FossilOrigin-Name: 7bee8c195f3fc27aaab13e493ad446a4f19201de3ac064ed6d8a3cbda7c69ee1

3 years agoExpand the getVarint32() macro in a few places, as the C-compiler seems to
drh [Sat, 2 Apr 2022 22:47:47 +0000 (22:47 +0000)] 
Expand the getVarint32() macro in a few places, as the C-compiler seems to
be able to optimize better when that macro is expanded manually.

FossilOrigin-Name: cd4fe34b98bf5ce26f3596c717edb73932f3b46ad6e9b4934d06b7b3c176a0d6

3 years agoFix harmless compiler warnings.
drh [Sat, 2 Apr 2022 20:08:48 +0000 (20:08 +0000)] 
Fix harmless compiler warnings.

FossilOrigin-Name: 8a3a3486358d076c34e515ac92663a04f0c7ff10f405094cb5b6ada0d5f05cdc

3 years agoEnsure that a zero-blob does not cause in invocation of memcpy() with a
drh [Sat, 2 Apr 2022 19:21:58 +0000 (19:21 +0000)] 
Ensure that a zero-blob does not cause in invocation of memcpy() with a
zero length and a NULL source pointer.

FossilOrigin-Name: 35441eb5e1447e01f2031837a4ede705bce34f87be27912278cc730abce6cf05

3 years agoMinor loop optimization in OP_MakeRecord.
drh [Sat, 2 Apr 2022 15:19:02 +0000 (15:19 +0000)] 
Minor loop optimization in OP_MakeRecord.

FossilOrigin-Name: 4350983b37879d3280432d90fef04f5cc4be1b3110b5435123d897e31b34db8a

3 years agoIn-line the sqlite3VdbeSerialPut() routine into the OP_MakeRecord opcode.
drh [Sat, 2 Apr 2022 14:30:58 +0000 (14:30 +0000)] 
In-line the sqlite3VdbeSerialPut() routine into the OP_MakeRecord opcode.
This allows some duplicate comparisons to be omitted, resulting in a size
reduction and performance increase.

FossilOrigin-Name: 6f4d6f212a3558c27be6e9dcf71cec43c424d445e5889c6e91dde84a19c5a2c1

3 years agoThe putVarint32() macro does not optimize well. So expand it into in-line
drh [Fri, 1 Apr 2022 21:01:37 +0000 (21:01 +0000)] 
The putVarint32() macro does not optimize well.  So expand it into in-line
code in places were performance is an issue.

FossilOrigin-Name: 390c239e53cf936a97b268dce8171f0b17050542ae64735ca8ef375fec2c9544

3 years agoLoop optimization in the OP_MakeRecord opcode.
drh [Fri, 1 Apr 2022 20:39:40 +0000 (20:39 +0000)] 
Loop optimization in the OP_MakeRecord opcode.

FossilOrigin-Name: 47a61fbd63928021098fbe492283f1afda7c293b3b2706c001192ae4ff1b2cbe

3 years agoIt is not necessary to de-ephermeralize the output registers in the
drh [Fri, 1 Apr 2022 20:19:36 +0000 (20:19 +0000)] 
It is not necessary to de-ephermeralize the output registers in the
OP_ResultRow opcode.  Omit that step for a size reduction and performance
increase.

FossilOrigin-Name: 8a07745aed1d0a4eead55d43f1923597b12371f307ecf5bc19c5a1db9a107a50

3 years agoThere is no need for sqlite3_step() to check for an OOM condition prior
drh [Fri, 1 Apr 2022 19:13:39 +0000 (19:13 +0000)] 
There is no need for sqlite3_step() to check for an OOM condition prior
to starting up.

FossilOrigin-Name: 44be7f46ba89289683ed0e123169ca9adb1018de03071d66de480c910a23d074

3 years agoOmit the Vdbe.doingRerun field for a slight size reduction and performance gain.
drh [Fri, 1 Apr 2022 19:04:13 +0000 (19:04 +0000)] 
Omit the Vdbe.doingRerun field for a slight size reduction and performance gain.

FossilOrigin-Name: e93297a9d775688e6274c54ba75b19fc1fe8b29b73b9b5e7f94f3f2ca37f045f

3 years agoNew macro ROUND8P() which works like ROUND8() but assumes that the input is
drh [Fri, 1 Apr 2022 18:45:11 +0000 (18:45 +0000)] 
New macro ROUND8P() which works like ROUND8() but assumes that the input is
already a multiple of the size of a pointer.  It becomes a no-op for
64-bit machines, giving a small size reduction and speed boost.

FossilOrigin-Name: d126f304cde66ebfe21a4967c22dcba0bac27cbce56318b14bd50051e49c978c

3 years agoProvide and use a version of sqlite3VdbeFreeCursor() that guarantees the
drh [Fri, 1 Apr 2022 18:19:04 +0000 (18:19 +0000)] 
Provide and use a version of sqlite3VdbeFreeCursor() that guarantees the
cursor pointer is not NULL.  This saves a few bytes of code space and a
few CPU cycles.

FossilOrigin-Name: cb5e6f8e265c91221227e5f15b95798c688773262407dd138d414103184702f6

3 years agoRemove an unnecessary branch from sqlite3VdbeReset().
drh [Fri, 1 Apr 2022 17:23:17 +0000 (17:23 +0000)] 
Remove an unnecessary branch from sqlite3VdbeReset().

FossilOrigin-Name: a7d79560a0efd6221ba59ce84bcb4fa94024a901ac4a45e192ddecc6e1b5c78c

3 years agoRefactor the Vdbe.iVdbeMagic field into Vdbe.eVdbeState. Split the RUNNING
drh [Fri, 1 Apr 2022 17:01:57 +0000 (17:01 +0000)] 
Refactor the Vdbe.iVdbeMagic field into Vdbe.eVdbeState.  Split the RUNNING
state into separate RUNNING and READY.  This gives a size reduction and
performance increase.

FossilOrigin-Name: 5a50a42fde9477868fad31099f5fe976437825fac44f8b3a4cf6c739c7667bbb

3 years agoAvoid a harmless uninitialized variable warning in PRAGMA incremental_vacuum.
drh [Fri, 1 Apr 2022 16:22:41 +0000 (16:22 +0000)] 
Avoid a harmless uninitialized variable warning in PRAGMA incremental_vacuum.

FossilOrigin-Name: 6d976f90dfe4886c3f4c062151af5c5ca7454d34b71172401b8c67acd2d663a0

3 years agoHave the sqlite3_context object carry the encoding for the prepared statement
drh [Fri, 1 Apr 2022 15:31:58 +0000 (15:31 +0000)] 
Have the sqlite3_context object carry the encoding for the prepared statement
that it represents, so that sqlite3_result() and similar can set the encoding
according to the prepared statement, even if the database encoding has
changed.
dbsqlfuzz c409b10d0a6bccf78ab00f47e1d29d42ee5b3565

FossilOrigin-Name: d4e19314f564126e180e091f9135c7bc55a10442edb46fbd3a4cfad21201dfa6

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