Commit Graph

21394 Commits

Author SHA1 Message Date
drh
5d762b2d1d Make a hard copy of strings in constraint checks prior to applying
OP_RealAffinity, to avoid problems with a pointer accounting assert.
This change is not strictly necessary - the correct answer is obtained
without it and no UB occurs - however the pointer accounting asserts are
useful to prevent other problems so it is a simple matter to bring this
piece into compliance.  Ticket [5ad2aa6921faa1ee]

FossilOrigin-Name: 89a9dad6330270a4c3b962f86a208088d2ea9883c7d291351a77f058e0ed8b0c
2019-12-22 20:29:25 +00:00
drh
6e827fa27d When constructing the virtual MATCH term of the WHERE clause for a virtual
table that is in a LEFT JOIN, be sure to set the correct Expr.iRightJoinTable
value.  This value does not appear to ever be used, except inside of a single
assert().  But it is good to set it correctly, nevertheless.  This fixes
ticket [7929c1efb2d67e98], which as far as I can tell is completely harmless.

FossilOrigin-Name: ef604882a275d3d5ebd4d5a08e3fe43e148f169b7d5c3a81464fbe7f54f3582a
2019-12-22 20:03:29 +00:00
drh
d262c2db8f In the WHERE clause debugging output (the .wheretrace output) show the
parent index of any WhereTerm that is a child.

FossilOrigin-Name: 7fc733328c5914c747e048c830522ec13e433c0a86388bae47b198a3e220c6c2
2019-12-22 19:41:12 +00:00
drh
6c1c85ca48 Fix to the optimization of check-in [a47efb7c8520a011] that reads the values
of expressions used in an index-on-expression directly from the index rather
than recomputing the value.  If the expression has a top-level COLLATE or
unlikely() operator, be sure to clear the corresponding flags prior to
converting it into a TK_COLUMN expression.  Failure to do this is most likely
harmless in production, but might cause an assertion fault in debugging builds.
Ticket [b0cb8aff561a6dcd].  Test cases in TH3.

FossilOrigin-Name: 56539e1c132632c075efc217ad5951a35e4459605ac128914aec3a7be1e25718
2019-12-22 18:55:04 +00:00
drh
db1954be0a Back out the asserts of check-ins [a500893b6f64aced] and [d9c9fe9f5ad3fc91]
as ticket [1b06916e01c82b66] demonstrates a case that refutes them.

FossilOrigin-Name: ddb17d92df194337a103c561ef46ced00db5e67e4551e82de7cb5ad7f457dd5f
2019-12-22 18:23:30 +00:00
drh
9524a7ea9f When parsing a CREATE TABLE from the sqlite_master table, delete the CHECK
constraints if there are any errors, since there might otherwise be attempts
to use those CHECK constraints if PRAGMA writable_schema=ON is set.
This undoes the fix in check-in [ea721b34477ab8b4] for a more general
solution.

FossilOrigin-Name: a982e6434cd66bfbe94d455f538bcbc4360b91572062d92acae6b77e9560e65d
2019-12-22 18:06:49 +00:00
dan
69843342de Ensure sqlite3WindowRewrite() is called on a SELECT statement before any terms aremoved from it as part of IN() clause processing. Fix for [f00d096ca].
FossilOrigin-Name: 8c856404b4e98d295449a4e89a41495dc007319a8e9c35c1a763718d7c5f67e8
2019-12-22 17:32:25 +00:00
dan
7a1d7c3968 Fix "PRAGMA data_version" so that it works the same way with locking_mode=PERSIST and journal_mode=PERSIST configured. Fix for 7a458c2a5f.
FossilOrigin-Name: 45748e2db028ffbda5d3e747493721a5a89af3fbc06823081a2f27f570e40e73
2019-12-22 14:29:55 +00:00
dan
e88af0179e Fix a spurious report of corruption from the fts3/4 integrity-check triggered by using the languageid option.
FossilOrigin-Name: 70815e273f511481c310dc33b3b49079901d891078fad49b663fbce06c77ecc2
2019-12-21 20:43:34 +00:00
drh
f4f31df02d When creating a new virtual table, ensure that the OP_ParseSchema opcode
processes the correct entry in the sqlite_master table even if there is
a second entry with the same name and table values due to database corruption
and the use of writable_schema=ON.  Dbsqlfuzz find.

FossilOrigin-Name: 4dbb6e1cb094f3428c74ea8bdd86ab63341fecce978a062968ca01423f382e90
2019-12-21 19:37:09 +00:00
drh
b0cbcd0edf When a corrupt schema is loaded using writable_schema=ON, the CHECK constraints
(or other expressions in the table definition) might not be fully resolved.
Ensure that the code generator can deal with this if the table is subsequently
used in a DML statement.  dbsqlfuzz find.

FossilOrigin-Name: ea721b34477ab8b49d182352c4bc198245933b850e9b6248b4f97600e80bb44b
2019-12-21 14:09:30 +00:00
drh
ed0c34857a Do not try to access a generated column through an index if the collating
sequence for the generated column is non-standard.
Part 2 of ticket [e0a8120553f4b082]

FossilOrigin-Name: 056bb8dcbdc45989c5c6e86d2966200062e3c01c382ec52aae37c828104b4496
2019-12-20 22:46:41 +00:00
drh
67b9ba1732 Apply real affinity to generated columns of type REAL that are extract from
an index.  Ticket [e0a8120553f4b082]

FossilOrigin-Name: 728ad39e3bd07a2503a95c68ed5bbc3f28fd97551d59f12a5fab25dc68227e99
2019-12-20 20:45:02 +00:00
drh
a513e591ae Debugging enhancment: Show the Expr.y.pTab pointer on TK_COLUMN nodes of
an expression tree in the treeview.

FossilOrigin-Name: 64154ac450e4366d18e7e867841877a69c1f978d3ba9b8754cc133248966731d
2019-12-20 20:08:56 +00:00
dan
879f1a1ea6 Fix a bad interaction between RBU and [df51ae19].
FossilOrigin-Name: 0b9d8a1202c4220fd2ef299b6194533c1bf4018a0cd2d13da7e22c1a7de05ffa
2019-12-20 20:03:21 +00:00
dan
42ae633ab9 Fix two more cases in fts5 where sqlite3_value_bytes() was being called before sqlite3_value_text(). Fix for e431c355.
FossilOrigin-Name: a1ba9a37d7a68a6d31f8197c6350589ebe6a12f4e3c193a178dd7ead8bcd565a
2019-12-20 19:41:01 +00:00
mistachkin
e99cb2da5f Export the public RBU entry points from the Win32 DLL.
FossilOrigin-Name: e62d1791f428b7a9bb14a59483f12d8ee08afbf4061a5e3be8f64787444301e7
2019-12-20 17:41:15 +00:00
drh
5d73272340 Debugging improvement: when tracing the VDBE, output the register value for
OP_Cast after the cast is completed.

FossilOrigin-Name: dc5f1d282d1e75f8a3791b0c95cb8f143b2a956323cb6c889d76d20db7f89257
2019-12-20 17:25:10 +00:00
drh
8cc8feae7e When computing dependencies on WHERE-clause terms, be sure to take into
account the FILTER clause of aggregate functions.  Problem reported by
Manuel Rigger.

FossilOrigin-Name: 3cc2b5709e66ef605c3b85ed13ae6cc9c3090e864ebc18859db36284b8f715b6
2019-12-20 15:35:56 +00:00
drh
8c7715d1cc Improved assert() statements on the OP_Column opcode.
FossilOrigin-Name: c538601e4c979ee59f18d19e6eb6296cebfa580fb029a18d5a3f0dd9393acb75
2019-12-20 14:37:56 +00:00
drh
40e9c8328e Load new dbsqlfuzz test cases into test/fuzzdata8.db.
FossilOrigin-Name: 01aeeb5c4c70a0f19651448e94ad5c6810cab3d6957b5bc7a9b4b8e0b887f3de
2019-12-20 14:24:26 +00:00
dan
394aa710f2 Fix a potential problem with ALTER TABLE commands on schemas that contains a triggers or view featuring a sub-query that uses an ON clause with a join that is not a LEFT JOIN.
FossilOrigin-Name: 365dd8b663d5a28af33556b2b3820c6b5482114ef741a1d82b55c6e154f3043a
2019-12-20 14:18:29 +00:00
drh
b2ab3dcff0 Fix harmless compiler warnings.
FossilOrigin-Name: 2bbd014c900e0d71fd30ec647739b82c5dc3aa237a0203f5a1db50593dae199e
2019-12-20 14:08:34 +00:00
dan
73b21382d4 Ensure fts5 consistently calls sqlite3_value_text() before sqlite3_value_bytes(). This matters when storing blobs in fts5 tables within utf-16 databases. Fix for [cf36cb4e02].
FossilOrigin-Name: c16305eba0eb14368f2631b9a82b7eb4483c93f3b31257ee7c33f9b00c344379
2019-12-20 13:24:11 +00:00
drh
1548d5276f Do not continue an ALTER TABLE tree walk of a subquery if a prior error
is seen in the tree.  Report the problem immediately, without continuing.

FossilOrigin-Name: 01ca865f31c0c817ede7f357401ef76cf311ae662397908464f53e1c147f5b6b
2019-12-20 12:55:21 +00:00
drh
0e5ce8029d Fix an assert() in btree.c that can fail if an INSERT is attempted on
a corrupted database while in PRAGMA writable_schema=ON.

FossilOrigin-Name: 07beb3629e648e7feae4e786191514339ac1d8f6ba5bb6e7cc8a04bc1f1cd6ab
2019-12-20 12:33:17 +00:00
drh
8428b3b437 Continuation of [e2bddcd4c55ba3cb]: Add another spot where it is necessary
to abort early due to prior errors in sqlite3WindowRewrite().

FossilOrigin-Name: cba2a2a44cdf138a629109bb0ad088ed4ef67fc66bed3e0373554681a39615d2
2019-12-19 22:08:19 +00:00
drh
6ad0e25fa4 Fix the regexp extension so that it correctly translates all over-length
3-byte UTF8 sequences into 0xfffd.

FossilOrigin-Name: 3d4c0bf8904135fa68c75801bfa738715cacc3b19dc8ad6ef550b11798d4b121
2019-12-19 21:11:48 +00:00
drh
8654186b02 When an error occurs while rewriting the parser tree for window functions
in the sqlite3WindowRewrite() routine, make sure that pParse->nErr is set,
and make sure that this shuts down any subsequent code generation that might
depend on the transformations that were implemented.  This fixes a problem
discovered by the Yongheng and Rui fuzzer.

FossilOrigin-Name: e2bddcd4c55ba3cbe0130332679ff4b048630d0ced9a8899982edb5a3569ba7f
2019-12-19 20:37:32 +00:00
drh
34ab941e5b Detect the invalid use of NULLS LAST on an INTEGER PRIMARY KEY definition
of a WITHOUT ROWID table.

FossilOrigin-Name: 4417c5bf0aabb34ed174f01afd981c924ae965a42128719d8d6735536631d12f
2019-12-19 17:42:27 +00:00
drh
54d501092d Fix the zipfile extension so that INSERT works even if the pathname of
the file being inserted is a NULL.  Bug discovered by the
Yongheng and Rui fuzzer.

FossilOrigin-Name: a80f84b511231204658304226de3e075a55afc2e3f39ac063716f7a57f585c06
2019-12-19 15:15:40 +00:00
drh
59c5679691 Fix incorrect SQL generated by the Lemon change of the previous check-in.
FossilOrigin-Name: fccfb8a9ed3c1df9f23762bb8df6fdf36a21118899e3fae41f451169a5f2c08e
2019-12-19 13:17:07 +00:00
drh
3e5f7fef33 Modify the parse.sql output file from Lemon so that the RULE table contains
a column with the complete text of the rule.

FossilOrigin-Name: 329cbb372d4d77f774f01a87d104c40ef42d713afbe76195b65f5ca205c5ea7b
2019-12-19 12:29:31 +00:00
drh
c29af653e6 Change an unreachable testcase() into an assert()
FossilOrigin-Name: 062e00c4d7e30155299339eaefe6cbe01953894baebf0af6d7ab3295b7436eb7
2019-12-18 21:22:40 +00:00
drh
396afe6f6a Continue to back away from the LEFT JOIN optimization of check-in [41c27bc0ff1d3135]
by disallowing query flattening if the outer query is DISTINCT.  Without this fix,
if an index scan is run on the table within the view on the right-hand side of the
LEFT JOIN, stale result registers might be accessed yielding incorrect results,
and/or an OP_IfNullRow opcode might be invoked on the un-opened table, resulting
in a NULL-pointer dereference.  This problem was found by the Yongheng and Rui fuzzer.

FossilOrigin-Name: 862974312edf00e9d1068115d1a39b7235b7db68b6d86b81d38a12f025a4748e
2019-12-18 20:51:58 +00:00
drh
6e1c45ef2e Add the --vdbe-debug option to fuzzcheck.
FossilOrigin-Name: 289158aa24b066c453d2bce4bc2dead1c56fb0b23c3f7c4810b34b13627cef34
2019-12-18 13:42:04 +00:00
drh
a7648f02e0 Enhancements to fuzzcheck on unix so that it captures signals and prints
the current test file and test number prior to terminating.

FossilOrigin-Name: ae7cbb246bff3717c283869ccf27ce83611422f3801176819465a8d96f6481bf
2019-12-18 13:02:18 +00:00
drh
8c72afaf33 Add a test case for fix in check-in [1ca0bd982ab1183b]
FossilOrigin-Name: 519864da8bb671941a64bf333c2086ad9a068b5f85759e7abd368f0706d3aefd
2019-12-18 09:17:55 +00:00
drh
94649b6159 Correctly unwind the savepoint stack if the database goes read-only in
the middle of a savepoint.

FossilOrigin-Name: a96d02b4ab8c70cc20b322e4fa3a4b8814f05c51f5d8b071ec9d69e7379f3ea5
2019-12-18 02:12:04 +00:00
drh
50efa58600 Remove an assert() in the code generator that can fail due to an invalid
INSERT statement.  The same assert() appears again in the VDBE and will fire
there if the problem persists in an SQL statement that does not contain
errors.  Gramfuzz find.

FossilOrigin-Name: 9bdd57cb9ad8ac1f4a0f1a3942d94ca5193109eeb1975343c4f0c7abf7135946
2019-12-18 01:31:21 +00:00
drh
75e95e1fcd When processing constant integer values in ORDER BY clauses of window
definitions (see check-in [7e4809eadfe99ebf]) be sure to fully disable
the constant value to avoid an invalid pointer dereference if the expression
is ever duplicated. This fixes a crash report from Yongheng and Rui.

FossilOrigin-Name: 1ca0bd982ab1183bbafce0d260e4dceda5eb766ed2e7793374a88d1ae0bdd2ca
2019-12-18 00:05:50 +00:00
drh
646975c521 Clean up the ExprList that holds the names of columns in a CTE before checking
for unused references in the ALTER TABLE implementation.

FossilOrigin-Name: 8223e79f987feda5c8e51ec52cec6798cca16d070b10558939e2888ca1a25b8e
2019-12-17 12:03:30 +00:00
drh
4dad7ed532 When a table is part of a LEFT JOIN and should be a completely NULL row due to
the semantics of a LEFT JOIN, make sure any generated columns on that row
evaluate to NULL.  Ticket [3b84b42943644d6f]

FossilOrigin-Name: 0271491438ad2a985aeff355173a8d0f1e5813954c82147bc68cb26cca5804c8
2019-12-16 16:52:22 +00:00
drh
d35bdd6c09 Ensure that all ON CONFLICT REPLACE indexes are sorted to the end of the list
of indexes for a table, even for weird cases where the same UNIQUE constraint
occurs twice with the ON CONFLICT REPLACE clause only on the second one.  This
avoids an out-of-order contraint processing problem that can arise due
to the optimization of check-in [469a62ca33081854].

FossilOrigin-Name: 1e3918ca2f2c1cfcfa44249b1d7b847d52cbb8d302a8d4a335c090cfdf22d7a1
2019-12-15 02:49:32 +00:00
drh
95866af326 Abort the OP_Savepoint opcode early if a virtual table xSync method fails,
perhaps due to an interrupt.

FossilOrigin-Name: 672e749aef7351de3c69b365c1f80c756fda4e261b5d2ac1faa01d3a7d5a4c49
2019-12-15 00:36:33 +00:00
drh
7e3f135c62 When a generated column expression is initially parsed, if it contains errors
convert the expression to a simple NULL.  This prevents additional pieces of
the expression tree that are allocated from lookaside from leaking into the
schema, where lookaside allocations are not allowed.

FossilOrigin-Name: a89b38605661e36d192df1d074383b704b34a959fcbc169837c0d4f6848f3208
2019-12-14 19:55:31 +00:00
drh
75f1076885 Due to the previous change, the p5 parameter to OP_VColumn no longer ever
contains extraneous bits, so change a testcase() into an assert() to show
as much.

FossilOrigin-Name: 5b4a88cd3b3a32b1242e0eb733cc0bc4becb830a887b8e6604a4c7452050e163
2019-12-14 18:08:22 +00:00
drh
99670abb82 Do not set OP_Column flags on the instructions generated by
sqlite3ExprCodeGetColumn() if the opcode generated is not really an
OP_Column, which might happen if the column is virtual.
Fix for ticket [b439bfcfb7deedc6]

FossilOrigin-Name: 2401e04730a156aa48787b91af4e516406cb7635145e430be62fd16481816237
2019-12-14 17:43:37 +00:00
drh
aac30f9b50 Make the sqlite3ExprCodeTarget() expression code generator routine robust
in the face of unknown opcodes - it simply generates a NULL value.

FossilOrigin-Name: f8e876c82a246ceed32b166f64e05dfe5ce4ab4c6820be60404109b43d36bb80
2019-12-14 15:01:55 +00:00
dan
5be1b20aec Fix problems in fts3 with processing corrupt records and undefined integer overflows.
FossilOrigin-Name: 3b873029ef1903f76442445343af3786cd59ee66b0e5e0e6b76a0b6b1b5eb88a
2019-12-14 14:15:21 +00:00
drh
e3a4f2cf77 Fix an utterly harmless "applying zero offset to null pointer" UB warning
in sqlite3AtoF():

FossilOrigin-Name: 052fdf5e58b41ccadaa5aac293ceb4d309ced661d46f3a52be9eb8d01d347a82
2019-12-13 23:38:57 +00:00
drh
0f1fa5de04 Patch to the page cache to avoid harmless pointer arithmetic that due to bugs
in the STD-C spec is technically UB.  This is to fix a harmless UBSAN
complaint that OSSFuzz is hitting.

FossilOrigin-Name: c29fc21288e37f81a1617c5e2961c575d3bca6a1d1b013b2e0a99774afb1dcdb
2019-12-13 21:24:46 +00:00
drh
2e2c8819f1 Ensure that there is a containing SELECT statement when processing a
normal aggregate function as if it were a window function.

FossilOrigin-Name: c1014e80b26131200a115beb86929a8f0ded2dd65b075e47373346c0f170576a
2019-12-13 11:42:56 +00:00
drh
0d98598507 *Remove* the macros, not just comment them out.
FossilOrigin-Name: e5dc2939d3e8694d648fc9b73b1174da5b1349e20fbb9cf1c91268939f308f89
2019-12-13 11:32:28 +00:00
drh
4ec4dd701f Remove unused macros formerly used to define built-in aggregate functions.
FossilOrigin-Name: 3ef0d44edd0354cda9b6237f992cb67a2170ee8f1f464b1f38ac36e3a133bc71
2019-12-13 11:31:47 +00:00
drh
77318a3c3f Factor out the conditional (which is only true for rare errors) from the
notValid() function in resolve.c, for a performance improvement and size
reduction.  Also cause failures to set the Expr node to a NULL operator so
that it does not cause problems later in case PRAGMA writable_schema=ON has
been set.  Test cases in TH3.

FossilOrigin-Name: c6af9f655b73200ecc0c4189698e421af6ca584babdc76e73a36d468b2eea1f9
2019-12-12 15:19:18 +00:00
drh
3ecc05bc3f Fix goofy string formatting in lemon.c that dates from the K&R-C days.
FossilOrigin-Name: 48ba5e5a2227257cebafacbb09e9dd91d9b89ab2d52a8b4e4113c1d017d95f41
2019-12-12 00:20:40 +00:00
drh
ce678c297b Improved tracing output from the LEMON-generated parser.
FossilOrigin-Name: 4d6d2fc046d586a1e5989bbb2757f13d0371fbfad0acf45a0e2fd77dffd8d8f9
2019-12-11 18:53:51 +00:00
drh
d4dae75f79 Strengthen check-in [83da4d4104ee1870] by ignoring *all* WHERE-clause
constraints for a virtual table that is the right table of a LEFT JOIN, 
as such constraints are never useful.
This fixes an issue discovered by Manuel Rigger.

FossilOrigin-Name: 840de36df1aaeb4bad9a7c18e97cc560ba3b8c629c4520a05bc456d67b3347b9
2019-12-11 16:22:53 +00:00
drh
a1ca00edd5 When trying to drop a virtual table that has no xDestroy method, invoke
the xDisconnect method rather than doing nothing, to avoid a memory leak.

FossilOrigin-Name: 1fa29a5f2a89b6a1ee067f9cb86de1b66455126349efe3502599fc7ad224170c
2019-12-11 15:07:09 +00:00
drh
31046a9f1f The xDestroy method of a module might be NULL if the schema is corrupt.
FossilOrigin-Name: 0457e7d1961ab1f63e31d9028a9064a895f5c3fcfb56ba25e4f37e90197e3a9f
2019-12-11 14:25:11 +00:00
drh
e94006eb42 Enhance LEMON to provide the ability to mark a rules as one that will never
reduce due to intervention of actions.  Use this new capability to designate
the EXPLAIN rule as NEVER-REDUCES.

FossilOrigin-Name: 136cdefb2f7b582ff1771ac7f9e733dc24c357605526cbfb1834937697c8a922
2019-12-10 20:41:48 +00:00
drh
8e8c88964c Use a statement journal on a CREATE VIRTUAL TABLE statement in case the
VCreate opcode fails.

FossilOrigin-Name: aa3b0eb8c3438ddd3b660bc6bce4b1f4a0e3b5ec897079445231ee1b61210d6a
2019-12-10 18:10:12 +00:00
drh
c075c505f3 Fix parser bugs: require a semicolon after an EXPLAIN command.
FossilOrigin-Name: 707a058a22bd00ef14431cee0d02048cf1be745c0ef5254eda76c325435738ff
2019-12-10 15:05:09 +00:00
dan
db5ed35609 Avoid a buffer overread in fts5 that could occur when parsing corrupt configuration records.
FossilOrigin-Name: 355afd77df21a2265871ca6d075f26b1fa121c7c2682cf512281944ff0c2186d
2019-12-10 03:40:11 +00:00
drh
b5f6243f6d Set the affinity of regular columns prior to computing the values of
generated columns.  Ticket [d7c3f125c925c522]

FossilOrigin-Name: d47d66e3d360d8aa6203a855228d2bc40d9a00d69c15f5066b7632d8fb1ed2cc
2019-12-10 02:48:41 +00:00
drh
0a8764ad7a Rename a local variable to avoid masking a function parameter and thus
causing a harmless compiler warning.

FossilOrigin-Name: f065cf003bd2a3a580cb5b9fa2eacd8be075fe8c2bbc5688e9a9406abbfb3804
2019-12-09 19:44:45 +00:00
drh
2bc5cf9ae9 Add a NEVER() to the ALTER TABLE fix in check-in [1d2e53a39b87e364]
FossilOrigin-Name: c7309ed3c7588c7e51e09418bf5cfd4611539b44c39cef9ed4ae0e385bae7625
2019-12-09 19:29:10 +00:00
drh
0824d5b9a5 The previous check-in was not quite correct, and introduced a new problem
with the USING clause.  Use this version instead.

FossilOrigin-Name: ed28aaa4851202111a502f883ca06359d89b25bba4055c29d7bce2b501cfcc68
2019-12-09 18:22:17 +00:00
drh
926f796e8f Ensure that the SrcList_item.colUsed field is set correctly (set to have a
1 for all columns of the table) when a generated column appears in the USING
clause of a join.

FossilOrigin-Name: 1923efb283e8840fa7436eb20b9d2174ef7cace1690d3b97b572a0db2048b8e3
2019-12-09 17:14:48 +00:00
drh
ebd70eedd5 Fix the NOT NULL verification logic in PRAGMA integrity_check so that it
works for generated columns whose value is the result of a comparison operator.
Ticket [bd8c280671ba44a7]

FossilOrigin-Name: f3b39c71b88cb6721f443de56cdce4c08252453a5e340b00a2bd88dc10c42400
2019-12-09 15:52:07 +00:00
drh
7a9698456d Fix a gramfuzz find. If a partial index that does not reference any column
of its table is used by an UPDATE statement in one-pass mode, then avoid the
use of OP_DeferredSeek since the seek might not be resolved prior to the
OP_Delete and OP_Insert that implement the UPDATE.

FossilOrigin-Name: e3398c5ffb060b2b26334b8598e2c63953741e2d6f5124dbd6bdfc8e94742539
2019-12-09 14:34:37 +00:00
dan
38096961c7 Avoid infinite recursion in the ALTER TABLE code when a view contains an unused CTE that references, directly or indirectly, the view itself.
FossilOrigin-Name: 1d2e53a39b87e364685e21de137655b6eee725e4c6d27fc90865072d7c5892b5
2019-12-09 08:13:43 +00:00
dan
c19e22f397 Fix possible null pointer dereferences in the fts5_expr() scalar function.
FossilOrigin-Name: c5d44143599f3fe98492b2b900fa3d77925c7be545096251055ceeab899a41f1
2019-12-09 02:20:37 +00:00
drh
bf9d0996b9 Fix incorrect column-usage accounting associated with generated columns
and added by check-in [6601da58032d18ae].  Fix for ticket [b92e5e8ec2cdbaa1].

FossilOrigin-Name: 9d75e1ccc72e9f536f45df3b24e9ecd25076cc1f7cf16b806b19e0e1b68e8326
2019-12-08 00:06:39 +00:00
drh
29cdbadf8a Correctly deal with multi-row VALUES clauses that contain window functions.
FossilOrigin-Name: 26d991f214db143976e2593d3564b5003eb3539a2728d1a0ccae2a2accece76f
2019-12-07 13:42:47 +00:00
drh
c7a046e282 Ignore type affinity for auxiliary columns in RTREE as it is too error-prone
to try to parse out the type from other constraints.
Ticket [8bf76328ac940d52]

FossilOrigin-Name: 7fa664ea0ea1e0283a9af50c9ff8dd360ee6042f9e491a136f53d9bcbbc9c7ef
2019-12-07 12:13:54 +00:00
drh
7fe2fc0dcb Fix a problem with foreign keys and generated columns discovered by
Manuel Rigger.

FossilOrigin-Name: 27c0fdab1ba4d4993b164eb4b777c63e82aa247c3fa406121dc8ed94970a0b35
2019-12-07 00:22:18 +00:00
drh
5102cf8df5 Early detection and reporting of too few columns in an rtree CREATE VIRTUAL
TABLE statement.

FossilOrigin-Name: ef73107f475e40e6bdd8b722e96992070f81fd2b7a3cb718ec8f251c89ca3e81
2019-12-06 19:07:44 +00:00
drh
0a64ddbe76 In the rtree extension, actively suppress extra tokens on the column names,
and be pedantic about column affinities.  Ticket [367a86e28859f1ff]

FossilOrigin-Name: 97fb5a72f91a44d579466e67c33aa862384c4d1c95c2010cf4ae9dbd172bbcfb
2019-12-06 13:10:29 +00:00
drh
39593e4f09 The check-in [b7810062ec2489e1] was not quite right in that it allowed an
oversized shift operation (which is UB in C) on some obscure inputs.  OSSFuzz
found the problem for us overnight.

FossilOrigin-Name: 62f2235adf796c72882b26313489cf49804ec3ec4972e0eee5034176cbb07f84
2019-12-06 11:48:27 +00:00
drh
e5748a5502 Further enhancements to RTREE, following up to check-in [f898d04cf272ef01]
so that constraints are allowed to be compared to strings that look like
numbers.  Ticket [aa573a787b8f1fdf]

FossilOrigin-Name: 32772dfd50b602c049d8c30bc28cde60a18b7495a997d728081f689ff417c956
2019-12-06 01:38:24 +00:00
drh
c6b24ab1b1 Do not allow UPSERT of a view.
FossilOrigin-Name: ebf897e861c19e214c57f1e73841b505182202cc8d7d39e24d5a1e5625e26b4a
2019-12-06 01:23:38 +00:00
drh
b6c947251b Fix to the rowvalue logic that avoids disabling rowvalue inequality
contraints on a virtual table when the virtual table sets the omit flag.
The logic has been incorrect since row-values were added.  However, this
does not come up often as very few virtual tables implement inequality
constraints using the omit flag.  Ticket [f096d191b6641daa]

FossilOrigin-Name: b7810062ec2489e1c5ca6638dbeb0892e4ce376c5c1834a31d1a332ebab8a871
2019-12-05 21:46:23 +00:00
drh
6c903845cd Documentation update: Clarify that the sqlite3_index_info.aConstraintUsage.omit
flag is a hint only and that the code generator is not obligated to follow
the hint.

FossilOrigin-Name: 7d3e3f6e7e55da41bf776fab094df54fb6a33b2967881d3184cf854c8a637518
2019-12-05 18:29:52 +00:00
drh
05fbfd827c Additional debugging information printed with the ".wheretrace 0x100" option.
No changes to normally delivered code.

FossilOrigin-Name: fc72ec52c92ca6a953e765b48e21d52021fdb23a2cd84f737da4e43c642f6a5d
2019-12-05 17:31:58 +00:00
drh
cb224ab139 Make sure the rowid of an RTREE virtual table has integer affinity.
Ticket [9fe487ba3c064b4e]

FossilOrigin-Name: 7ae8c0d52f6aa7f27537216f85456ef49dade040366cfb250c789206ecd4dc5a
2019-12-05 14:42:26 +00:00
dan
e6dc1e5b70 Fix a problem in ALTER TABLE that could occur if an index, view or trigger in the schema features an expression of the form ((SELECT ...) IN ()) where the SELECT statement uses a CTE.
FossilOrigin-Name: 7e5ad8e0ab7ee91a5ccb19a9654d6a036233f74d2fdc45f7315feb3d9d035fd4
2019-12-05 14:31:43 +00:00
drh
348d7f64f2 Be strict about type enforcement on rowid look-ups in the RTREE extension.
Ticket [30e2c183b6b356e4]

FossilOrigin-Name: d43e0efb9642037dd751cfed13438e71cfceb50e14a0ec603880c6c3be2e93b1
2019-12-05 13:34:13 +00:00
drh
674a9b3425 Enhance the RTREE extension so that it give correct query results even if
the query uses non-numeric constraints.  Ticket [a55ab6d97d01ecbc]

FossilOrigin-Name: f898d04cf272ef0130dcae146cb86d8630b10a6f19aecfc2fa70e97e082bd51c
2019-12-05 00:44:47 +00:00
drh
a634c9e653 Window functions are never constant.
FossilOrigin-Name: 35f0b5a8c7921f7419eeb11be8201fd6988047042fcaeffa297fc322bc480c1f
2019-12-04 19:45:52 +00:00
drh
d63b69b8a2 Ensure that an ALWAYS() in the rename logic really is always true, even
for faulty inputs.

FossilOrigin-Name: 54410f0e7710542d5159d0449898598d2b7f7676bfd993644ca47da1bf1fcdac
2019-12-04 15:08:58 +00:00
dan
8f4076223d Fix an assert() failure that could occur in ALTER TABLE code when the schema contains a view that uses a CTE.
FossilOrigin-Name: 75b04a4b0d2e65bfcd02cf4e0b6d8f1954957c590814a9b8f9a9ee2adc2ec022
2019-12-04 14:26:38 +00:00
dan
8aa706e748 Fix a buffer overread that could occur in fts3 with corrupt %_stat records.
FossilOrigin-Name: e01fdbf9f700e1bd9dd5283c65547d10d26ce4f4506d3cfef9e1087aecdc2305
2019-12-04 03:46:50 +00:00
drh
f68bf5fbe6 Fix an incorrect NEVER() macro.
FossilOrigin-Name: 96b6a76da09a94182414ec1a56da91728c37329d2b55f889e433054ca21605ce
2019-12-04 03:31:29 +00:00
dan
fcc057db25 Fix a double-free that could occur when a component of a compound SELECT with an ORDER BY clause uses named window definitions.
FossilOrigin-Name: 92893b7980cbb0c6e26bc0b21390a717193205c9897fea5f26476462928897f9
2019-12-04 01:42:07 +00:00
dan
0232dade79 Avoid a crash that could occur when a database containing a table with a temp trigger that has the same name as a temp table is detached.
FossilOrigin-Name: c4cb9708d48ead10ee9543f86878be8382cd6e850950d5384c95254bac4a8d6e
2019-12-03 03:34:06 +00:00
drh
d79967adbe Avoid a harmless zero offset of a null pointer in FTS3, so as to not provoke
unnecessary warnings from run-time checkers.

FossilOrigin-Name: 85d95abec4a596eb3ffd2ea19b4067dc1a6970264222ed5d69e75764ac21597c
2019-12-03 03:31:11 +00:00
drh
22e6f67c51 Avoid computing a zero offset of a null pointer, which though this is
technically harmless, is upsetting to pedantic run-time checkers.

FossilOrigin-Name: 3ce804e99bbef83d49ec309157448a7c1422725606516cef904e6122aadd3922
2019-12-03 02:51:50 +00:00
drh
ca7a26b5a1 Do not allow a term in the WHERE clause of the query to qualify a partial
index on the right table of a LEFT JOIN.  Ticket [7f39060a24b47353]

FossilOrigin-Name: 4066a34da7bcdcece6c438c27f3a11bc49b8c8373b7e1603f30f6225e2bc800a
2019-11-30 19:29:19 +00:00