]> git.ipfire.org Git - thirdparty/sqlite.git/log
thirdparty/sqlite.git
5 years agoMerge updates from trunk. explain-improvements
drh [Sat, 21 Mar 2020 14:05:56 +0000 (14:05 +0000)] 
Merge updates from trunk.

FossilOrigin-Name: 2383aa2cb864734cccca6c98605df6026c732cbfb9a173660d2993dc63970f63

5 years agoBack out the sqlite3_stmt_mode() and EXPLAIN TABLES enhancements, but keep
drh [Sat, 21 Mar 2020 03:40:21 +0000 (03:40 +0000)] 
Back out the sqlite3_stmt_mode() and EXPLAIN TABLES enhancements, but keep
the other miscellaneous improvements to EXPLAIN that were implemented while
adding the above:  Turn magic numbers into symbolic constants.
Add the sqlite3MemPrint() interface accessible to the debugger.  Improve
the performance and reduce the code size.

FossilOrigin-Name: 62aece66774587590bf7f88883cca1c1e76866e9df93bb1a17c4d9db894f06aa

5 years agoRecompute the set of columns used for each table when the table is
drh [Sat, 21 Mar 2020 00:05:53 +0000 (00:05 +0000)] 
Recompute the set of columns used for each table when the table is
involved in query flattening.

FossilOrigin-Name: a9bb71ba708ba72255ba8d18c9856e38ddf53eae2d61c8435149354fb2b2459e

5 years agoAvoid an undefined integer overflow in fts3 by detecting data structure corruption...
dan [Fri, 20 Mar 2020 20:18:49 +0000 (20:18 +0000)] 
Avoid an undefined integer overflow in fts3 by detecting data structure corruption earlier.

FossilOrigin-Name: 86e98ddc19470410ccc6d2cf4ad56ef0bc5a23b7fbe6331b8cae374689f54529

5 years agoAdd the EXPLAIN TABLES syntax that uses SQLITE_STMTMODE_TABLELIST. Seems sqlite3_stmt_mode
drh [Fri, 20 Mar 2020 20:00:10 +0000 (20:00 +0000)] 
Add the EXPLAIN TABLES syntax that uses SQLITE_STMTMODE_TABLELIST.  Seems
to work, but not well-tested.

FossilOrigin-Name: e7343ce7514f61eb1aeba22ab83da5b05779080db394332e2e90b4d54cabe123

5 years agoFurther simplification of the EXPLAIN logic. Fix the test errors from
drh [Fri, 20 Mar 2020 17:49:37 +0000 (17:49 +0000)] 
Further simplification of the EXPLAIN logic.  Fix the test errors from
the previous check-in.

FossilOrigin-Name: 5eaba9af1c35ea7b7c08cad7d0d9b5a4b63b11b3177bb84a570ce1cea44b9f57

5 years agoRevamp the EXPLAIN infrastructure to facilitate sqlite3_stmt_mode(). The
drh [Fri, 20 Mar 2020 16:13:41 +0000 (16:13 +0000)] 
Revamp the EXPLAIN infrastructure to facilitate sqlite3_stmt_mode().  The
currently code mostly works, but there are test failures.  This is an
incremental check-in.

FossilOrigin-Name: e9e17e2125dbbafd5da4adb3bd2893735fa4d0aaa5f3daee75f866cb32231a8d

5 years agoInitial code for a proposed new sqlite3_stmt_mode() API.
drh [Thu, 19 Mar 2020 21:17:11 +0000 (21:17 +0000)] 
Initial code for a proposed new sqlite3_stmt_mode() API.
This is an incomplete snapshot of a work-in-progress.

FossilOrigin-Name: 3cf7537b5e14e218218b18b3c0c668c950a71fcddc68a5faf0f197519718a6c2

5 years agoChagnes the ESCAPE clause on the LIKE operator to overwrite wildcard
drh [Thu, 19 Mar 2020 18:13:28 +0000 (18:13 +0000)] 
Chagnes the ESCAPE clause on the LIKE operator to overwrite wildcard
characters, in order ot match the behavior of PosgreSQL.

FossilOrigin-Name: 11e0844f71e8f2d27ce9363fb505e02fd7795c61dae0b3886cf0d8df4484dd97

5 years agoFix an integer overflow problem with the dbstat virtual table that comes up
drh [Thu, 19 Mar 2020 17:27:52 +0000 (17:27 +0000)] 
Fix an integer overflow problem with the dbstat virtual table that comes up
when trying to analyze a corrupt database.

FossilOrigin-Name: 1d64f4a8af81fe1235fffa54884d8f842a48ff6a33d6172f0cd65bf42fe8b2a1

5 years agoFix a typo in a comment. No changes to code.
drh [Thu, 19 Mar 2020 15:57:03 +0000 (15:57 +0000)] 
Fix a typo in a comment.  No changes to code.

FossilOrigin-Name: 3a51919ac23ae7312d78905334dc97742b517a7476052a85aa07945d9c77697b

5 years agoFix handling of window functions in aggregate queries that have no GROUP BY clause...
dan [Mon, 16 Mar 2020 18:52:53 +0000 (18:52 +0000)] 
Fix handling of window functions in aggregate queries that have no GROUP BY clause. Also remove a faulty assert causing the error reported in [618156e3].

FossilOrigin-Name: 38e3dd389d142e520c71139ec84aa3c7722992af28a5f93a7f16e0ea176b74bb

5 years agoAt the end of the right-hand table loop of a LEFT JOIN that uses an IN
drh [Mon, 16 Mar 2020 03:07:53 +0000 (03:07 +0000)] 
At the end of the right-hand table loop of a LEFT JOIN that uses an IN
operator in the ON clause, put the OP_IfNoHope operator after the
OP_IfNotOpen operator, not before, to avoid a (harmless) uninitialized
register reference.  Ticket [82b588d342d515d1]

FossilOrigin-Name: 8b437b47266ec2d80d85eafcfdd6949556d6c28d9d67d5f43d89799f0f5b7bd0

5 years agoRemove stray comment characters at the end of an #ifdef that were
drh [Thu, 12 Mar 2020 17:54:39 +0000 (17:54 +0000)] 
Remove stray comment characters at the end of an #ifdef that were
accidently left in the previous check-in.

FossilOrigin-Name: ea914bec81c49625072fc9d23faa048300f3a0421e069d303b7203edcdfb3743

5 years agoFix comments and strengthen assert() statements associated with the
drh [Thu, 12 Mar 2020 17:28:27 +0000 (17:28 +0000)] 
Fix comments and strengthen assert() statements associated with the
OPFLAG_SEEKEQ and BTREE_SEEK_EQ flags.

FossilOrigin-Name: 231749213854756b599b33413b17b35186f17889b0c73f109fa9db726b415558

5 years agoDo not factor out constant functions into the initialization section of a
drh [Wed, 11 Mar 2020 19:56:26 +0000 (19:56 +0000)] 
Do not factor out constant functions into the initialization section of a
prepared statement, because even though they are constant, they can still
throw exceptions.  Instead, put such functions in an OP_Once block.  This
fixes ticket [3c9eadd2a6ba0aa5] and causes COALESCE() and CASE...END to
be short-circuit.

FossilOrigin-Name: c5f96a085db9688a09793f52ce1ecf033c2e6e2e5873a19fe0fb374b242b317f

5 years agoRename sqlite3ExprCodeAtInit() to sqlite3ExprCodeRunJustOnce(). do-not-factor-functions
drh [Wed, 11 Mar 2020 19:41:49 +0000 (19:41 +0000)] 
Rename sqlite3ExprCodeAtInit() to sqlite3ExprCodeRunJustOnce().
Other changes to make the new code cleaner.  Test cases added.

FossilOrigin-Name: d7f18489978fdbbe3ab317485518cac91a75416ccef55898301afdd76d3b415b

5 years agoDo not factor out constant functions into the initialization section at the
drh [Wed, 11 Mar 2020 17:58:27 +0000 (17:58 +0000)] 
Do not factor out constant functions into the initialization section at the
end of the prepared statement, be cause if they throw an exception, it will
abort the statement even if the function is never called.  Better to put
constant functions in an OP_Once block.

FossilOrigin-Name: 97a18a5cd701848a9660385e31bffe2c397e3cfe57ccdb876f44d08c00d1d39a

5 years agoThis variant to the fix for ticket [e0c2ad1aa8a9c691] uses fewer CPU cycles.
drh [Wed, 11 Mar 2020 02:04:15 +0000 (02:04 +0000)] 
This variant to the fix for ticket [e0c2ad1aa8a9c691] uses fewer CPU cycles.

FossilOrigin-Name: fb5a8a9edd0a4f979d6c30278d4ddc73c651f56ae989b4e5983fca36887c5ceb

5 years agoEnhanced detection logic for preventing the use of static schema expressions
drh [Tue, 10 Mar 2020 19:24:38 +0000 (19:24 +0000)] 
Enhanced detection logic for preventing the use of static schema expressions
by code generating routines.

FossilOrigin-Name: 5f60b527b938c0778e8f725c635ce0dc5ed7a4e01fd6252aa2cdb64da2f625bc

5 years agoFurther changes to ensure that expressions held in table and index definitions
drh [Tue, 10 Mar 2020 18:55:41 +0000 (18:55 +0000)] 
Further changes to ensure that expressions held in table and index definitions
do not get passed down into code generator logic where they might be modified.

FossilOrigin-Name: f45f5de000834da5b23cdcf12c3f0e3073287756afe06bdb77b95fb65b250258

5 years agoMake a copy of the expression that defines a value of a generated column
drh [Tue, 10 Mar 2020 13:35:04 +0000 (13:35 +0000)] 
Make a copy of the expression that defines a value of a generated column
before sending it to the code generator routines.

FossilOrigin-Name: 03d201c041c17579e791c73fe6babd60b9f892a84ffd1470851f8eb2857d3990

5 years agoApply the correct affinity transformations when pulling values off of the
drh [Tue, 10 Mar 2020 11:50:43 +0000 (11:50 +0000)] 
Apply the correct affinity transformations when pulling values off of the
sorter index used for GROUP BY.  Ticket [e0c2ad1aa8a9c691]

FossilOrigin-Name: 101f7dea75a203f1f3aa422a607ef701eb0901ba4d5e8d1075cd350454a61956

5 years agoThe sqlite3ExprCodeFactorable() routine should make a copy of non-factorable
drh [Tue, 10 Mar 2020 02:57:37 +0000 (02:57 +0000)] 
The sqlite3ExprCodeFactorable() routine should make a copy of non-factorable
expressions, as they might be coming from a DEFAULT or generated column
in a table constraint.

FossilOrigin-Name: a2d6f108c5d07559b125823a04c9cb072c80be80d7913097891a6192c7e1e225

5 years agoCleaner separation of the STAT4-specific logic in the implementation of
drh [Mon, 9 Mar 2020 18:26:11 +0000 (18:26 +0000)] 
Cleaner separation of the STAT4-specific logic in the implementation of
ANALYZE.

FossilOrigin-Name: 3df07e5a9a3781a4cf866fc6ee0e5c6f9cd7ca35ce0a6eb3aa7f5f3502e0ffae

5 years agoEnhancements to the ".import" command of the CLI.
drh [Mon, 9 Mar 2020 15:39:39 +0000 (15:39 +0000)] 
Enhancements to the ".import" command of the CLI.

FossilOrigin-Name: cab1834cfc71f71bfed3c5170a0ba40a39385c3b2c50b7c6b6f09cc830dd1b1e

5 years agoFix typos in RowSet.
pdr [Mon, 9 Mar 2020 03:21:33 +0000 (03:21 +0000)] 
Fix typos in RowSet.

FossilOrigin-Name: 86465c08f4d629a296332a7985937326ac43ea2822c5651bf03862cd79d370fc

5 years agoFix typos in the Lemon documentation.
drh [Mon, 9 Mar 2020 01:02:45 +0000 (01:02 +0000)] 
Fix typos in the Lemon documentation.

FossilOrigin-Name: 35f1f151ac478d6b46f3685d2565c35108ef74bd33ce96fb65300d3c303b289b

5 years agoAvoid a redundant NULL check
pdr [Sun, 8 Mar 2020 13:33:58 +0000 (13:33 +0000)] 
Avoid a redundant NULL check

FossilOrigin-Name: 25dc53f6608dd9b8b4e8d8ee22e194a6d41d15811781752797cb42fc22ee1317

5 years agoReport an error if the main, or any other, database encoding is modified by an extern...
dan [Thu, 5 Mar 2020 18:04:09 +0000 (18:04 +0000)] 
Report an error if the main, or any other, database encoding is modified by an external process (perhaps using the backup API) after the db has been opened.

FossilOrigin-Name: 895bd20b29e223496e1585483c6ce3335ae9050f2e5de4d6b69d0e40df396862

5 years agoChange the sqlite3.pDfltColl (the default collating sequence for the
drh [Thu, 5 Mar 2020 16:13:24 +0000 (16:13 +0000)] 
Change the sqlite3.pDfltColl (the default collating sequence for the
database connection) so that it is the collating sequence appropriate for
the database encoding, not the UTF8 collating sequence.  This helps to
ensure that the database encoding collation is always used, even for
expressions that do not have an defined collating sequence.
Ticket [1b8d7264567eb6fc].

FossilOrigin-Name: 4a5851893c3d71cc823b6ab5df5e58a852cd322fff26290f1ea05b63d67f564a

5 years agoWhen printing the OP_CollSeq opcode for EXPLAIN listings, include the
drh [Thu, 5 Mar 2020 14:19:49 +0000 (14:19 +0000)] 
When printing the OP_CollSeq opcode for EXPLAIN listings, include the
text encoding with the name of the collating sequence.

FossilOrigin-Name: eb5c1b77d1c55fc286ff8fccfd61e21cb67aec92d6f93b093b9af5c32165d82b

5 years agoFix a false-positive in the debugging logic that attempts to detect the
drh [Tue, 3 Mar 2020 20:48:12 +0000 (20:48 +0000)] 
Fix a false-positive in the debugging logic that attempts to detect the
use of uninitialized registers inside triggers.
Ticket [c4c56482ced89d90]

FossilOrigin-Name: 0463576b5de0a1ee71530f0e4988fc9cceda79148520bea2c67f1fbc4a99cea9

5 years agoRemove an invalid assert() on the debugging logic that checks to ensure that
drh [Tue, 3 Mar 2020 20:04:29 +0000 (20:04 +0000)] 
Remove an invalid assert() on the debugging logic that checks to ensure that
register values are not used after they go stale.  Ticket [d165ad781b39d574].

FossilOrigin-Name: bd94d7d052734460904c687756231f8aa243a2252f07f742dd1e437aa940f536

5 years agoImproved detection of corruption in the interior nodes of a segment btree
drh [Tue, 3 Mar 2020 01:16:04 +0000 (01:16 +0000)] 
Improved detection of corruption in the interior nodes of a segment btree
in FTS3/4.

FossilOrigin-Name: cc99447ac923166104e8a7c75088ed95279f4491b30cfa37dc3ee5e005dd9fac

5 years agoEnhance the fuzzcheck test program so that it is able to simulate OOM errors
drh [Mon, 2 Mar 2020 16:31:21 +0000 (16:31 +0000)] 
Enhance the fuzzcheck test program so that it is able to simulate OOM errors
in the same way that dbsqlfuzz does.

FossilOrigin-Name: a65c8d4e26b2428ecb8232a4a6a44443aa1701319223397e61a823a5aa1827de

5 years agoFix a faulty assert() statement in the stale-register detection logic.
drh [Mon, 2 Mar 2020 01:50:48 +0000 (01:50 +0000)] 
Fix a faulty assert() statement in the stale-register detection logic.
Ticket [da5a09be6dabbf42].

FossilOrigin-Name: 219c296cc8cab13fa12b64c297bc4a98d8e21491309d97a031edf89ae77fce75

5 years agoEnsure that the NULL-scan pass counter is initialized when a ORDER BY NULLS LAST
drh [Mon, 2 Mar 2020 01:16:33 +0000 (01:16 +0000)] 
Ensure that the NULL-scan pass counter is initialized when a ORDER BY NULLS LAST
is used on the right table of a LEFT JOIN.  Ticket [e12a0ae526bb51c7].

FossilOrigin-Name: 704bb9a39acbee420c1d6ac9eb1466a02dd77d3334b938bfddf235973129b5fe

5 years agoFix a problem with window functions occuring within sub-selects that are part of...
dan [Sat, 29 Feb 2020 17:19:42 +0000 (17:19 +0000)] 
Fix a problem with window functions occuring within sub-selects that are part of an OR term in a WHERE clause of the outer SELECT.

FossilOrigin-Name: 1e174ed0d29366eb56ad1a0cc8defcb440b426bfd9525aed2f93468248606efc

5 years agoIn the CLI, add the ".oom" command for debugging builds.
drh [Sat, 29 Feb 2020 15:53:48 +0000 (15:53 +0000)] 
In the CLI, add the ".oom" command for debugging builds.

FossilOrigin-Name: 9c3136a722715952d155aae55cbc6d1fb921c6940d8e7d3e32fcba000f6ac1ed

5 years agoThe RTREE extension behaves has if data columns have type REAL, so we
drh [Fri, 28 Feb 2020 16:04:28 +0000 (16:04 +0000)] 
The RTREE extension behaves has if data columns have type REAL, so we
should actually declare them as REAL so that automatic indexes handle
them correctly.  Ticket [e63b4d1a65546532]

FossilOrigin-Name: 85a9b6a92fd5805d5936f02d555af395441607b9eb5f4dae63560b5e65663b00

5 years agoIn sqlite3changeset_apply(), ensure that DELETE and UPDATE changes are always execute...
dan [Thu, 27 Feb 2020 17:16:45 +0000 (17:16 +0000)] 
In sqlite3changeset_apply(), ensure that DELETE and UPDATE changes are always executed on main database tables, not similarly named temp tables, as documented. INSERT statements are already being handled correctly.

FossilOrigin-Name: f71a13d072398c9fc3556f42d75159cc2d0edc2c42f6c47f64503a7fbbca6e37

5 years agoFix harmless compiler warnings from MSVC.
drh [Thu, 27 Feb 2020 16:21:39 +0000 (16:21 +0000)] 
Fix harmless compiler warnings from MSVC.

FossilOrigin-Name: 951b39ca74c9bd933139e099d5555283278db475f410f202c162e5d1e6aef933

5 years agoOptimization for "SELECT min(x) FROM tbl" where "x" is indexed and NOT NULL. This...
dan [Thu, 27 Feb 2020 15:07:16 +0000 (15:07 +0000)] 
Optimization for "SELECT min(x) FROM tbl" where "x" is indexed and NOT NULL. This also allows similar queries on NOT NULL virtual table columns to be optimized.

FossilOrigin-Name: 59726777934e201d94e99ca693f0fda4ebfb1c7883d0258ce542f63f9924c28c

5 years agoExtra zero terminators on the end of the blank filename returned by
drh [Thu, 27 Feb 2020 13:54:18 +0000 (13:54 +0000)] 
Extra zero terminators on the end of the blank filename returned by
sqlite3PagerFilename() for an in-memory database.  This helps the result
work better with sqlite3_filename_journal() and similar functions.

FossilOrigin-Name: 63e533d28e87bbb10e0c611de4b79d22aae291b163fe59d1f95dcad9ab3939e4

5 years agoEnsure that the filename passed into the xFullPathname method of the VFS is
drh [Thu, 27 Feb 2020 11:32:14 +0000 (11:32 +0000)] 
Ensure that the filename passed into the xFullPathname method of the VFS is
acceptable as an argument to sqlite3_uri_parameter().  The interface spec does
not guarantee this, but it has been so historically and some applications
have come to depends on it.

FossilOrigin-Name: bfb09371d452d5d4dacab2ec476880bc729952f44ac0e5de90ea7ba203243c8c

5 years agoUpdate the fuzzcheck test module so that it avoids inserting text values
drh [Tue, 25 Feb 2020 20:05:58 +0000 (20:05 +0000)] 
Update the fuzzcheck test module so that it avoids inserting text values
that contain embedded NULs in the XSQL table.  Fix some legacy entries in
the test/fuzzdata8.db that had embedded NULs.  Add in new dbsqlfuzz cases
that have accumulated over on the dbsqlfuzz project for a while.

FossilOrigin-Name: 47d4240c4a837e829f593bb2aad7563010838f55345e7a0d8e2ea79462aeeb3c

5 years agoIf STAT4 determines that a WHERE clause term that is not used by an index
drh [Mon, 24 Feb 2020 17:05:09 +0000 (17:05 +0000)] 
If STAT4 determines that a WHERE clause term that is not used by an index
has very high probability of being true, then do not use that term to reduce
the estimated output row count.

FossilOrigin-Name: 40739c793b0e98a3bae296d3a1f74944edcdd4cc33c26b417fde4eaf6f14d062

5 years agoRework this changes so that instead of setting the WhereTerm.truthProb when stat4-truthprob
drh [Mon, 24 Feb 2020 16:46:08 +0000 (16:46 +0000)] 
Rework this changes so that instead of setting the WhereTerm.truthProb when
a term is seen to be of low selectivity, it merely sets a new flag
(the TERM_HIGHTRUTH flag) which causes whereLoopOutputAdjust() to ignore
that term.

FossilOrigin-Name: 4558163b6a525990f0f1b6629dbb76daf49bcaf1ddbaf0c50fe05ce9ee480ff8

5 years agoDisable the new analyzeG.test module if not building with STAT4.
drh [Mon, 24 Feb 2020 13:35:34 +0000 (13:35 +0000)] 
Disable the new analyzeG.test module if not building with STAT4.

FossilOrigin-Name: 4a9d3005769e0398183b03a3e132e3946b9d1c48073af2e0559d7beeac3245c0

5 years agoMerge bugfix from trunk.
drh [Mon, 24 Feb 2020 13:26:29 +0000 (13:26 +0000)] 
Merge bugfix from trunk.

FossilOrigin-Name: b542dee9de843c19664c19df7435c6034d23d0d213804d588ec0ff599082d576

5 years agoFix a problem with ALTER TABLE for views that have a nested FROM clause.
drh [Sun, 23 Feb 2020 17:34:45 +0000 (17:34 +0000)] 
Fix a problem with ALTER TABLE for views that have a nested FROM clause.
Ticket [f50af3e8a565776b].

FossilOrigin-Name: c431b3fd8fd0f6a6974bba3e9366b0430ec003d570e7ce70ceefbcff5fe4b6fa

5 years agoDo not activate the truthProb adjustment mechanism if the truth probability
drh [Sat, 22 Feb 2020 18:27:48 +0000 (18:27 +0000)] 
Do not activate the truthProb adjustment mechanism if the truth probability
is less than the heuristic value, as there could be correlations unknown to
stat4.  Also add additional tracing output to make truthProb adjustments more
visible.

FossilOrigin-Name: c535fea147ce5c6e4aab25d3c85a3f53a7364c5b5ee10fb6d393c5911a02be7e

5 years agoAdd new test file analyzeG.test, containing a test for the change on this branch.
dan [Sat, 22 Feb 2020 17:32:00 +0000 (17:32 +0000)] 
Add new test file analyzeG.test, containing a test for the change on this branch.

FossilOrigin-Name: 243ab1852a2291595527ea1f26e78ad83eda285ae28f876bc1c703677f495cfa

5 years agoWhen stat4 information is available, try to use it to improve the truth
drh [Sat, 22 Feb 2020 16:58:49 +0000 (16:58 +0000)] 
When stat4 information is available, try to use it to improve the truth
probability of WHERE clause terms that do not participate in the index.

FossilOrigin-Name: 1babd6ec5d60e2c34aa1c0285ead768a88004218468e97262411973fe3487022

5 years agoIn the OP_Column opcode, if the cursor is marked NullRow (due to being the
drh [Sat, 22 Feb 2020 13:01:19 +0000 (13:01 +0000)] 
In the OP_Column opcode, if the cursor is marked NullRow (due to being the
right table of a LEFT JOIN that does not match) and the cursor is the table
cursor for an OR-optimization with a covering index, then do not substitute
the covering index cursor, since the covering index cursor does not have
the NullRow flag set.  Ticket [aa4378693018aa99]

FossilOrigin-Name: f02030b3403d67734bba471a91ad5bfdb03ddf6fdc3ef14808a04495e43b0470

5 years agoAdd test case for previous commit.
dan [Thu, 20 Feb 2020 14:11:08 +0000 (14:11 +0000)] 
Add test case for previous commit.

FossilOrigin-Name: 14d14eb537075c6ac77513b1e7305bed8bc01a9034dfb763fd96f76400f2b705

5 years agoEarly-out on the INTERSECT query processing following an error.
drh [Thu, 20 Feb 2020 14:08:51 +0000 (14:08 +0000)] 
Early-out on the INTERSECT query processing following an error.

FossilOrigin-Name: a67cf5b7d37d5b1484be32092635faafd8f76e5881898cd9435517c4b287d663

5 years agoFix a potential NULL pointer dereference following OOM. Problem discovered
drh [Wed, 19 Feb 2020 15:39:46 +0000 (15:39 +0000)] 
Fix a potential NULL pointer dereference following OOM.  Problem discovered
by dbsqlfuzz.  Test case in TH3.

FossilOrigin-Name: 5aeb5a2d295e10d5fc1d456b3acaf8ac13c04cb5bb71a8c4571541d366e95887

5 years agoRemove a NEVER() macro and add a test case to cause its argument to be true.
drh [Tue, 18 Feb 2020 23:58:58 +0000 (23:58 +0000)] 
Remove a NEVER() macro and add a test case to cause its argument to be true.

FossilOrigin-Name: ee034fe916448e953ee7824e5c0db99a36a0ad138ebfb25f751bf84cb80a8fa7

5 years agoAdd the new sqlite3_create_filename() and sqlite3_free_filename() interfaces
drh [Tue, 18 Feb 2020 19:49:48 +0000 (19:49 +0000)] 
Add the new sqlite3_create_filename() and sqlite3_free_filename() interfaces
for use by Shims.  Use these interfaces inside the multiplexor.

FossilOrigin-Name: 9469f36ac89e4b75d0ab25fefbeff25201992c53141da915dcaa017083cab6db

5 years agoConvert invalid surrogates to 0xfffd when translating UTF.
drh [Mon, 17 Feb 2020 23:08:16 +0000 (23:08 +0000)] 
Convert invalid surrogates to 0xfffd when translating UTF.

FossilOrigin-Name: 7fab1393c2b22b1f3b159b631e06e7e0d3900850ee249c38e4d3cdd0aacf637e

5 years agoA better (smaller and faster) solution to ticket [4374860b29383380].
drh [Mon, 17 Feb 2020 19:25:07 +0000 (19:25 +0000)] 
A better (smaller and faster) solution to ticket [4374860b29383380].

FossilOrigin-Name: abc473fb8fb999005dc79a360e34f97b3b25429decf1820dd2afa5c19577753d

5 years agoTake care when checking the table of a TK_COLUMN expression node to see if the
drh [Mon, 17 Feb 2020 00:12:04 +0000 (00:12 +0000)] 
Take care when checking the table of a TK_COLUMN expression node to see if the
table is a virtual table to first ensure that the Expr.y.pTab pointer is not
null due to generated column optimizations.  Ticket [4374860b29383380].

FossilOrigin-Name: 9d0d4ab95dc0c56e053c2924ed322a9ea7b25439e6f74599f706905a1994e454

5 years agoAvoid an infinite recursion on an illegal recursive definition of an
drh [Sun, 16 Feb 2020 17:40:35 +0000 (17:40 +0000)] 
Avoid an infinite recursion on an illegal recursive definition of an
fts5vocab table.

FossilOrigin-Name: 109ee07433b274a39954cef62bf67d47bcda960df9bef56127210ebf1c3c104c

5 years agoFix problems in the constant propagation optimization that were introduced
drh [Thu, 13 Feb 2020 22:12:35 +0000 (22:12 +0000)] 
Fix problems in the constant propagation optimization that were introduced
by check-in [1c3e5c20a9e6f501].  Fix for ticket [1dcb4d44964846ad]

FossilOrigin-Name: c9a8defcef35a1fee6bcbb88252a2d0076dabe8381b0128b2257b5b5cc494e0f

5 years agoDisallow the skip-scan optimization in the absence of sqlite_stat1 data.
drh [Thu, 13 Feb 2020 14:51:54 +0000 (14:51 +0000)] 
Disallow the skip-scan optimization in the absence of sqlite_stat1 data.

FossilOrigin-Name: e0c6b8bdb76fcd4f08c89ff20dce6a33ef3c11752e1e919fec5c4e7d423c4b93

5 years agoOmit O_NOFOLLOW from the open() call when opening /dev/null, since /dev/null
drh [Thu, 13 Feb 2020 13:45:04 +0000 (13:45 +0000)] 
Omit O_NOFOLLOW from the open() call when opening /dev/null, since /dev/null
is a symlink on Solaris, we are told.

FossilOrigin-Name: 0c683c43a62fe25c6cb765e4a31556ec91a7c21af79349b3d7eeb13f73dd1cdc

5 years agoFix an incorrect assert() statement that was added yesterday.
drh [Thu, 13 Feb 2020 11:46:47 +0000 (11:46 +0000)] 
Fix an incorrect assert() statement that was added yesterday.
Tickets [41c1456a6e61c0e7] and [fb8c538a8f57ae2a].

FossilOrigin-Name: abfb043ebb0c55fdc2be58255bc852b13865d81fa4c2e0dbe8c375810557aafe

5 years agoIncrease the default upper bound on the number of parameters in a single
drh [Wed, 12 Feb 2020 20:50:20 +0000 (20:50 +0000)] 
Increase the default upper bound on the number of parameters in a single
SQL statement to 32766 (from 999).

FossilOrigin-Name: 2def75693a8ae002375aff80db0e6c970c75f75e8b6ba64f2c518712badb0ae8

5 years agoWhen determining whether an == or IS constraint in a WHERE clause makes an ORDER...
dan [Wed, 12 Feb 2020 11:57:35 +0000 (11:57 +0000)] 
When determining whether an == or IS constraint in a WHERE clause makes an ORDER BY term redundant, consider the collation sequence used by the == or IS comparison, not the collation sequence of the comparison expression itself. Possible fix for [fb8c538a8f].

FossilOrigin-Name: 16aed5d0c63dcdc2054dbb8a4b6b992476640433bf81e19301e6db5a3fc82633

5 years agoMark the sha1() extension function as SQLITE_DETERMINISTIC.
drh [Mon, 10 Feb 2020 19:24:49 +0000 (19:24 +0000)] 
Mark the sha1() extension function as SQLITE_DETERMINISTIC.

FossilOrigin-Name: 7d8dcfb95cea732e7588e7505bf80a171dd2e371b164c9435c6ac286060df6df

5 years agoFix the build for when SQLITE_VDBE_COVERAGE is used.
drh [Mon, 10 Feb 2020 13:29:10 +0000 (13:29 +0000)] 
Fix the build for when SQLITE_VDBE_COVERAGE is used.

FossilOrigin-Name: 084381649edf374ccc5664f136055109a31d4c3a19c4ae2ee5275f630507a2a3

5 years agoDuring byte-code generation, strive to avoid jumps that merely jump to the
drh [Fri, 7 Feb 2020 19:44:13 +0000 (19:44 +0000)] 
During byte-code generation, strive to avoid jumps that merely jump to the
following instruction.

FossilOrigin-Name: bcf876e67e75f6709f2b25683a3952bbbb87c672bb9d7af456feebc0ab9f6c31

5 years agoSimplify the code by removing the unsupported and undocumented
drh [Fri, 7 Feb 2020 01:12:53 +0000 (01:12 +0000)] 
Simplify the code by removing the unsupported and undocumented
SQLITE_HAS_CODEC compile-time option

FossilOrigin-Name: 5a877221ce90e7523059353a68650c5fdd28ed032807afc2f10afbfbf864bdfe

5 years agoThere is no need to keep track of the number of changed rows or of the
drh [Thu, 6 Feb 2020 20:46:08 +0000 (20:46 +0000)] 
There is no need to keep track of the number of changed rows or of the
last-insert-rowid while running VACUUM.

FossilOrigin-Name: a8a7c05b16f6c73ac55c359fbf62cae4a76eb0d105a3c53e9f47cede9fd85916

5 years agoUnroll the comparison loop inside keywordCode() for to avoid unnecessary
drh [Thu, 6 Feb 2020 15:38:43 +0000 (15:38 +0000)] 
Unroll the comparison loop inside keywordCode() for to avoid unnecessary
comparisions and thus help that routine run faster.

FossilOrigin-Name: cec5f920f5c2a963f88329a08a443fc04be2dd6f7f2d840be63c0ab1de898f0a

5 years agoSeparate OP_IdxInsert and OP_SorterInsert into completely separate opcodes,
drh [Thu, 6 Feb 2020 13:57:08 +0000 (13:57 +0000)] 
Separate OP_IdxInsert and OP_SorterInsert into completely separate opcodes,
helping each one to run a little faster.

FossilOrigin-Name: 447d71f0867a11f789eba164ea77470b3ae4953927556304b0861cf690250776

5 years agoRemove dead code from the sqlite3_filename_database() function.
drh [Thu, 6 Feb 2020 13:09:56 +0000 (13:09 +0000)] 
Remove dead code from the sqlite3_filename_database() function.

FossilOrigin-Name: 1b6185550f2bcfa11513898984f1fc2029e0356e9acdc786c5c4a8006b1da2ba

5 years agoFix some fts3 problems found by usan.
dan [Thu, 6 Feb 2020 10:55:10 +0000 (10:55 +0000)] 
Fix some fts3 problems found by usan.

FossilOrigin-Name: fb7ccf61bed8d862986eda7096bec3df5947f1d1c88f27e7d9c8acf420f40c50

5 years agoSmall size reduction and performance improvement in the
drh [Wed, 5 Feb 2020 18:28:17 +0000 (18:28 +0000)] 
Small size reduction and performance improvement in the
sqlite3VdbeMemFromBtree() interface used to pull content out of the b-tree
and into an sqlite3_value object.

FossilOrigin-Name: ae6dd8d3e921670ee6450453b54245dd71bcfff3fd1bc7fdb7cf4cf9585c3375

5 years agoEnable more detailed log messages in SQLITE_ENABLE_CORRUPT_PGNO builds if database...
dan [Tue, 4 Feb 2020 20:01:44 +0000 (20:01 +0000)] 
Enable more detailed log messages in SQLITE_ENABLE_CORRUPT_PGNO builds if database corruption is encountered.

FossilOrigin-Name: 57c36a293e16bb4d9652874124ee1447bef278e08664bc8dd0070a0ee2ef1173

5 years agoExtend the OP_Copy-coalesce optimization fix of check-in [b36126c1889e323c]
drh [Tue, 4 Feb 2020 01:41:44 +0000 (01:41 +0000)] 
Extend the OP_Copy-coalesce optimization fix of check-in [b36126c1889e323c]
so that it is also correctly disabled by the CASE operator.
Ticket [9d3666754ac37d5a].

FossilOrigin-Name: 29a969d6b1709b80d9cb88b60971e4eb021f7f5f8ee9a619be74b833a78a35ef

5 years agoFix a problem with the byte-code decompiler that was inserted by the
drh [Tue, 4 Feb 2020 00:55:27 +0000 (00:55 +0000)] 
Fix a problem with the byte-code decompiler that was inserted by the
enhancements at [4248980a356f659b]

FossilOrigin-Name: af63e95dcdd6e9741cdddc3698e857e3b8be40048d3036f939f3583e517c4eff

5 years agoCosmetic change to the xfer-optimization to put the OP_RowData opcode closer
drh [Mon, 3 Feb 2020 19:56:51 +0000 (19:56 +0000)] 
Cosmetic change to the xfer-optimization to put the OP_RowData opcode closer
to the corresponding OP_Insert opcode.  This makes it slightly easier to read
and understand the code.

FossilOrigin-Name: 0ea2dbfc9088561d62c3456803cb08d357e4e60f1d21f6ed37315564be4957d3

5 years agoIncrease the version number to 3.32.0.
drh [Mon, 3 Feb 2020 12:25:18 +0000 (12:25 +0000)] 
Increase the version number to 3.32.0.

FossilOrigin-Name: 8130bbb4217bd4a4db1f6bf97115a60bee8b29943bed0c7bdf54bba5edbed8fc

5 years agoOn an INSERT or UPDATE, perform affinity conversions on new data prior to
drh [Sat, 1 Feb 2020 21:03:27 +0000 (21:03 +0000)] 
On an INSERT or UPDATE, perform affinity conversions on new data prior to
running CHECK constraints.  Ticket [86ba67afafded936].

FossilOrigin-Name: 1d4f86201dab9a22df9ef8175a7ebf3640e97cdb23a06fb454b4c69bfda3a9af

5 years agoFix the comment display for the OP_Function opcode. And at the same time,
drh [Sat, 1 Feb 2020 17:38:24 +0000 (17:38 +0000)] 
Fix the comment display for the OP_Function opcode.  And at the same time,
improve the comment generating logic to make use of the newer
sqlite3_str_appendf() interface.

FossilOrigin-Name: 4248980a356f659b10b12c778592996d53c91fae4ea50c8566678da176bdd152

5 years agoMerge the sqlite3CodecQueryParameters() fix into trunk.
drh [Sat, 1 Feb 2020 14:20:35 +0000 (14:20 +0000)] 
Merge the sqlite3CodecQueryParameters() fix into trunk.

FossilOrigin-Name: a812f533693a3605f297199ae0320d663e872208675e86860c5c1803943943aa

5 years agoFix a problem in sqlite3CodecQueryParameters() that was introduced by the
drh [Sat, 1 Feb 2020 13:30:39 +0000 (13:30 +0000)] 
Fix a problem in sqlite3CodecQueryParameters() that was introduced by the
query parameter encoding changes for the 3.31.1 release.

FossilOrigin-Name: cc65ca541265bd7061ed8f5ec9a54f3c384c41019c5ea1c68dcaabeff3495839

5 years agoFix a minor typo in a comment in the btreeinfo extension.
drh [Fri, 31 Jan 2020 14:52:19 +0000 (14:52 +0000)] 
Fix a minor typo in a comment in the btreeinfo extension.

FossilOrigin-Name: b5a66d10f4bbaf10def7b50b9ed98b05b41bb2c2af5ab9a90f6cda61169ab123

5 years agoFix a problem with the processing of IN(...) constraints handled by virtual table...
dan [Wed, 29 Jan 2020 15:03:01 +0000 (15:03 +0000)] 
Fix a problem with the processing of IN(...) constraints handled by virtual table implementations that do not set the "omit" flag when the virtual table column contains at least one NULL value.

FossilOrigin-Name: dcb4838757ca49cf149a6e883b3eb0ac8a075147387a078280dfabe39b1a3e8d

5 years agoAdd a test case for commit [ffd8bb93].
dan [Wed, 29 Jan 2020 13:56:35 +0000 (13:56 +0000)] 
Add a test case for commit [ffd8bb93].

FossilOrigin-Name: bcd5b37b8ebd67537f60c0061fcbc70b2aebebb88d6fb842ccf321a3e20c122c

5 years agoRemove a NEVER() that is in fact reachable. Test cases in dbsqlfuzz and TH3.
drh [Wed, 29 Jan 2020 13:50:11 +0000 (13:50 +0000)] 
Remove a NEVER() that is in fact reachable.  Test cases in dbsqlfuzz and TH3.

FossilOrigin-Name: ffd8bb9351fbd8c1285491d4e10734f6816689de6042d640c178a5ecda75a5ef

5 years agoAdd new memory barriers during initialization.
drh [Wed, 29 Jan 2020 13:10:50 +0000 (13:10 +0000)] 
Add new memory barriers during initialization.

FossilOrigin-Name: a9b2adc5d61790abd86839d12e7ecb98a85d7e4cde5f94558530e32449d9e483

5 years agoModify a couple of FTS test cases so that they work on big-endian platforms.
drh [Wed, 29 Jan 2020 12:37:59 +0000 (12:37 +0000)] 
Modify a couple of FTS test cases so that they work on big-endian platforms.

FossilOrigin-Name: b20503aaf5b6595afafee6aa2bc6276354a62b0f583f6d94e31fedfdfc130347

5 years agoFaster decoding of 32-bit variable-length integers in cases were we do not
drh [Tue, 28 Jan 2020 20:27:42 +0000 (20:27 +0000)] 
Faster decoding of 32-bit variable-length integers in cases were we do not
need to know the number of bytes in the encoding.

FossilOrigin-Name: 59a31b16b54a0068c81ee65bc2fa905c2c826e98da3a7ffd8c3ea860a2827b4a

5 years agoSmall performance improvement to the key-comparision routine for strings.
drh [Tue, 28 Jan 2020 20:09:39 +0000 (20:09 +0000)] 
Small performance improvement to the key-comparision routine for strings.

FossilOrigin-Name: 41454499a2b63c5fe6fae2d2085773a5f7d869250dcbe669929d20c961211f70

5 years agoReinstate the optimization of converting "a IN (C)" into "a=C" but only
drh [Tue, 28 Jan 2020 18:09:53 +0000 (18:09 +0000)] 
Reinstate the optimization of converting "a IN (C)" into "a=C" but only
if C is a constant.  If the RHS is a table column, the complications of
managing affinity and collations become too involved to mess with.

FossilOrigin-Name: 8ac26a23d7f0ef29c5eb007c7467181f8b96102c8600ea8a5b15cc7584af27bd

5 years agoFix a 4 byte OOB read in test_multiplex.c.
dan [Tue, 28 Jan 2020 16:55:32 +0000 (16:55 +0000)] 
Fix a 4 byte OOB read in test_multiplex.c.

FossilOrigin-Name: 912148913c11d98e48119a2c1fa7a0e52f318af36e7e2491d968ffde286c949f