Commit Graph

21664 Commits

Author SHA1 Message Date
drh ba25c7e29f Remove stray comment characters at the end of an #ifdef that were
accidently left in the previous check-in.

FossilOrigin-Name: ea914bec81c49625072fc9d23faa048300f3a0421e069d303b7203edcdfb3743
2020-03-12 17:54:39 +00:00
drh 576d0a9fd9 Fix comments and strengthen assert() statements associated with the
OPFLAG_SEEKEQ and BTREE_SEEK_EQ flags.

FossilOrigin-Name: 231749213854756b599b33413b17b35186f17889b0c73f109fa9db726b415558
2020-03-12 17:28:27 +00:00
drh 2267a7fa87 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
2020-03-11 19:56:26 +00:00
drh 9b258c54e4 Rename sqlite3ExprCodeAtInit() to sqlite3ExprCodeRunJustOnce().
Other changes to make the new code cleaner.  Test cases added.

FossilOrigin-Name: d7f18489978fdbbe3ab317485518cac91a75416ccef55898301afdd76d3b415b
2020-03-11 19:41:49 +00:00
drh 38dfbdae8a 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
2020-03-11 17:58:27 +00:00
drh 8d5cea6b61 This variant to the fix for ticket [e0c2ad1aa8a9c691] uses fewer CPU cycles.
FossilOrigin-Name: fb5a8a9edd0a4f979d6c30278d4ddc73c651f56ae989b4e5983fca36887c5ceb
2020-03-11 02:04:15 +00:00
drh e7375bfa72 Enhanced detection logic for preventing the use of static schema expressions
by code generating routines.

FossilOrigin-Name: 5f60b527b938c0778e8f725c635ce0dc5ed7a4e01fd6252aa2cdb64da2f625bc
2020-03-10 19:24:38 +00:00
drh 5cf1b611a2 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
2020-03-10 18:55:41 +00:00
drh 24e399038b 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
2020-03-10 13:35:04 +00:00
drh 0c76e892d9 Apply the correct affinity transformations when pulling values off of the
sorter index used for GROUP BY.  Ticket [e0c2ad1aa8a9c691]

FossilOrigin-Name: 101f7dea75a203f1f3aa422a607ef701eb0901ba4d5e8d1075cd350454a61956
2020-03-10 11:50:43 +00:00
drh 088489e8d9 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
2020-03-10 02:57:37 +00:00
drh afa1ecac9b Cleaner separation of the STAT4-specific logic in the implementation of
ANALYZE.

FossilOrigin-Name: 3df07e5a9a3781a4cf866fc6ee0e5c6f9cd7ca35ce0a6eb3aa7f5f3502e0ffae
2020-03-09 18:26:11 +00:00
drh ccb3781673 Enhancements to the ".import" command of the CLI.
FossilOrigin-Name: cab1834cfc71f71bfed3c5170a0ba40a39385c3b2c50b7c6b6f09cc830dd1b1e
2020-03-09 15:39:39 +00:00
pdr 45dc9ca46b Fix typos in RowSet.
FossilOrigin-Name: 86465c08f4d629a296332a7985937326ac43ea2822c5651bf03862cd79d370fc
2020-03-09 03:21:33 +00:00
drh ed5e66881e Fix typos in the Lemon documentation.
FossilOrigin-Name: 35f1f151ac478d6b46f3685d2565c35108ef74bd33ce96fb65300d3c303b289b
2020-03-09 01:02:45 +00:00
pdr db9cb17dc7 Avoid a redundant NULL check
FossilOrigin-Name: 25dc53f6608dd9b8b4e8d8ee22e194a6d41d15811781752797cb42fc22ee1317
2020-03-08 13:33:58 +00:00
dan 0ea2d42ac3 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
2020-03-05 18:04:09 +00:00
drh 42a630b1da 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
2020-03-05 16:13:24 +00:00
drh 4cf2121e1c When printing the OP_CollSeq opcode for EXPLAIN listings, include the
text encoding with the name of the collating sequence.

FossilOrigin-Name: eb5c1b77d1c55fc286ff8fccfd61e21cb67aec92d6f93b093b9af5c32165d82b
2020-03-05 14:19:49 +00:00
drh f5cfe6f2c4 Fix a false-positive in the debugging logic that attempts to detect the
use of uninitialized registers inside triggers.
Ticket [c4c56482ced89d90]

FossilOrigin-Name: 0463576b5de0a1ee71530f0e4988fc9cceda79148520bea2c67f1fbc4a99cea9
2020-03-03 20:48:12 +00:00
drh d346fe0ab5 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
2020-03-03 20:04:29 +00:00
drh b3f0d92b91 Improved detection of corruption in the interior nodes of a segment btree
in FTS3/4.

FossilOrigin-Name: cc99447ac923166104e8a7c75088ed95279f4491b30cfa37dc3ee5e005dd9fac
2020-03-03 01:16:04 +00:00
drh 39b3bcf8ef Enhance the fuzzcheck test program so that it is able to simulate OOM errors
in the same way that dbsqlfuzz does.

FossilOrigin-Name: a65c8d4e26b2428ecb8232a4a6a44443aa1701319223397e61a823a5aa1827de
2020-03-02 16:31:21 +00:00
drh a2ec2e4843 Fix a faulty assert() statement in the stale-register detection logic.
Ticket [da5a09be6dabbf42].

FossilOrigin-Name: 219c296cc8cab13fa12b64c297bc4a98d8e21491309d97a031edf89ae77fce75
2020-03-02 01:50:48 +00:00
drh 7f05d52c4c 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
2020-03-02 01:16:33 +00:00
dan 0a21ea997d 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
2020-02-29 17:19:42 +00:00
drh 4a3a3eb3d7 In the CLI, add the ".oom" command for debugging builds.
FossilOrigin-Name: 9c3136a722715952d155aae55cbc6d1fb921c6940d8e7d3e32fcba000f6ac1ed
2020-02-29 15:53:48 +00:00
drh 2826918d10 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
2020-02-28 16:04:28 +00:00
dan 9e5ecdc172 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
2020-02-27 17:16:45 +00:00
drh be284e4ece Fix harmless compiler warnings from MSVC.
FossilOrigin-Name: 951b39ca74c9bd933139e099d5555283278db475f410f202c162e5d1e6aef933
2020-02-27 16:21:39 +00:00
dan 67e2bb92df 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
2020-02-27 15:07:16 +00:00
drh 47a60d4518 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
2020-02-27 13:54:18 +00:00
drh df97d43930 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
2020-02-27 11:32:14 +00:00
drh a8781d9d93 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
2020-02-25 20:05:58 +00:00
drh f575c1cf06 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
2020-02-24 17:05:09 +00:00
drh f06cdde2cf 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
2020-02-24 16:46:08 +00:00
drh 35d3cb80c4 Disable the new analyzeG.test module if not building with STAT4.
FossilOrigin-Name: 4a9d3005769e0398183b03a3e132e3946b9d1c48073af2e0559d7beeac3245c0
2020-02-24 13:35:34 +00:00
drh 2ed1b0e753 Merge bugfix from trunk.
FossilOrigin-Name: b542dee9de843c19664c19df7435c6034d23d0d213804d588ec0ff599082d576
2020-02-24 13:26:29 +00:00
drh 0990c415f6 Fix a problem with ALTER TABLE for views that have a nested FROM clause.
Ticket [f50af3e8a565776b].

FossilOrigin-Name: c431b3fd8fd0f6a6974bba3e9366b0430ec003d570e7ce70ceefbcff5fe4b6fa
2020-02-23 17:34:45 +00:00
drh cea1951e80 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
2020-02-22 18:27:48 +00:00
dan 5c19346451 Add new test file analyzeG.test, containing a test for the change on this branch.
FossilOrigin-Name: 243ab1852a2291595527ea1f26e78ad83eda285ae28f876bc1c703677f495cfa
2020-02-22 17:32:00 +00:00
drh 89efac94fd 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
2020-02-22 16:58:49 +00:00
drh e8c4f03266 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
2020-02-22 13:01:19 +00:00
dan 8a64d62d31 Add test case for previous commit.
FossilOrigin-Name: 14d14eb537075c6ac77513b1e7305bed8bc01a9034dfb763fd96f76400f2b705
2020-02-20 14:11:08 +00:00
drh 5f69512404 Early-out on the INTERSECT query processing following an error.
FossilOrigin-Name: a67cf5b7d37d5b1484be32092635faafd8f76e5881898cd9435517c4b287d663
2020-02-20 14:08:51 +00:00
drh 1cfee74a28 Fix a potential NULL pointer dereference following OOM. Problem discovered
by dbsqlfuzz.  Test case in TH3.

FossilOrigin-Name: 5aeb5a2d295e10d5fc1d456b3acaf8ac13c04cb5bb71a8c4571541d366e95887
2020-02-19 15:39:46 +00:00
drh 4b9e736898 Remove a NEVER() macro and add a test case to cause its argument to be true.
FossilOrigin-Name: ee034fe916448e953ee7824e5c0db99a36a0ad138ebfb25f751bf84cb80a8fa7
2020-02-18 23:58:58 +00:00
drh 4defdddc31 Add the new sqlite3_create_filename() and sqlite3_free_filename() interfaces
for use by Shims.  Use these interfaces inside the multiplexor.

FossilOrigin-Name: 9469f36ac89e4b75d0ab25fefbeff25201992c53141da915dcaa017083cab6db
2020-02-18 19:49:48 +00:00
drh 0184a256e3 Convert invalid surrogates to 0xfffd when translating UTF.
FossilOrigin-Name: 7fab1393c2b22b1f3b159b631e06e7e0d3900850ee249c38e4d3cdd0aacf637e
2020-02-17 23:08:16 +00:00
drh 78d1d225d8 A better (smaller and faster) solution to ticket [4374860b29383380].
FossilOrigin-Name: abc473fb8fb999005dc79a360e34f97b3b25429decf1820dd2afa5c19577753d
2020-02-17 19:25:07 +00:00