Commit Graph

21678 Commits

Author SHA1 Message Date
drh
f7f6dbf501 Enhance the treeview system to show the SrcList_item.colUsed field for
FROM clause elements.

FossilOrigin-Name: 8a5c539b77aa174c048a504d211c56902075f9b42b654e1f8cc5767739e5fcc9
2020-03-21 22:03:32 +00:00
dan
7d76fad8eb Simplify some of the code modified by the previous commit.
FossilOrigin-Name: 04abadb545d1b34bdd74d62becb3bfd83aceee373fd6b4b708d5ad53f41d9464
2020-03-21 20:58:05 +00:00
dan
31f170f396 Ensure that "main" can always be used to refer to the main database, even if it has been renamed using SQLITE_DBCONFIG_MAINDBNAME.
FossilOrigin-Name: 682b426f5658254e63dff02c960b557fb33cb3e944fdd14faa0aa9988af7269a
2020-03-21 15:41:55 +00:00
dan
465c2b8964 Consolidate some code on this branch.
FossilOrigin-Name: a85c63daa640e02fdfd891a05a1a09e848c9621a5dd6e112338451008623ecbb
2020-03-21 15:10:40 +00:00
drh
2c3629e1c9 Change a bitfield in sqlite3_stmt into an unsigned character, for slightly
smaller code and better performance.

FossilOrigin-Name: 0d4d3c642494ad494b4ec937215eaf833158e62e5ae59ed981d6b546220c13b8
2020-03-21 15:07:27 +00:00
drh
62b6e1d042 Performance optimization in sqlite3VdbeMakeReady().
FossilOrigin-Name: aa92f9b95f95d40cc58910da87168a5bd440f71deb072dc651bb15936315786c
2020-03-21 14:22:27 +00:00
drh
2aee514b4c Recompute the set of columns used for each table when the table is
involved in query flattening.

FossilOrigin-Name: a9bb71ba708ba72255ba8d18c9856e38ddf53eae2d61c8435149354fb2b2459e
2020-03-21 00:05:53 +00:00
dan
00bd55e1ae Allow "main" to be used to refer to the main database even after SQLITE_DBCONFIG_MAINDBNAME has been used to assign another alias.
FossilOrigin-Name: 75c85ca32f9ae4a28fd8f8ff2f7639599413d22af706e9799a0e76cc560d14eb
2020-03-20 20:54:28 +00:00
dan
ec8e689a20 Avoid an undefined integer overflow in fts3 by detecting data structure corruption earlier.
FossilOrigin-Name: 86e98ddc19470410ccc6d2cf4ad56ef0bc5a23b7fbe6331b8cae374689f54529
2020-03-20 20:18:49 +00:00
drh
589c787620 Chagnes the ESCAPE clause on the LIKE operator to overwrite wildcard
characters, in order ot match the behavior of PosgreSQL.

FossilOrigin-Name: 11e0844f71e8f2d27ce9363fb505e02fd7795c61dae0b3886cf0d8df4484dd97
2020-03-19 18:13:28 +00:00
drh
f0a2172d1d Fix an integer overflow problem with the dbstat virtual table that comes up
when trying to analyze a corrupt database.

FossilOrigin-Name: 1d64f4a8af81fe1235fffa54884d8f842a48ff6a33d6172f0cd65bf42fe8b2a1
2020-03-19 17:27:52 +00:00
drh
91a23dc299 Fix a typo in a comment. No changes to code.
FossilOrigin-Name: 3a51919ac23ae7312d78905334dc97742b517a7476052a85aa07945d9c77697b
2020-03-19 15:57:03 +00:00
dan
553948e514 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
2020-03-16 18:52:53 +00:00
drh
14c98a4f40 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
2020-03-16 03:07:53 +00:00
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