Commit Graph

21470 Commits

Author SHA1 Message Date
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
d335bc40a6 Change the default lookaside configuration to 40 slots of 1200-bytes each.
This actually works out to 30 big slots and 93 small slots using the 
mini-lookaside allocator.  We get the same (or better) lookaside coverage
but with 72KB less memory per connection.

FossilOrigin-Name: 47b71a84d1262c4bf6ad4f4a91820fd63593f08ae9efa144199d44972225e073
2019-12-13 16:04:52 +00:00
drh
e6068027ca Cleanup and performance enhancements for mini-lookaside.
FossilOrigin-Name: 74805668430051032ae9b256c84e252755ee03075fc08293c948675ed40ec280
2019-12-13 15:48:21 +00:00
drh
ee5b6dd393 Merge fixes from trunk.
FossilOrigin-Name: 9c471195f6d3e4b00e2d0f909b306a4036352082dca5f016a8eece226e82163d
2019-12-13 12:14:23 +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
85d9411c09 Reduce the size of ExprList to 24-bytes per entry, down from 32-bytes per
entry.  This helps keep lookaside allocations in the mini-size.

FossilOrigin-Name: bda92d92bf69a73bc6dd498f92578ad6e81111a3f97bc8724d1720e7283a83b6
2019-12-13 01:12:21 +00:00
drh
c4938ea2ba Tie up the loose ends in the ExprList size reduction.
FossilOrigin-Name: 59d0f3afe5249a2a6453fe7bc810c2c7beb896d3800174c7c90f9304c0b1ad88
2019-12-13 00:49:42 +00:00
drh
cbb9da337e Work toward reducing the incremental size of an ExprList object to 24-byte
per entry, from 32-bytes (on a 64-bit machine).  This helps the new
mini-lookaside allocator to run better by avoiding excessive reallocs.
The current change mostly works, but still has a few loose ends to tie up.
This check-in is merely a snapshot to save my work.

FossilOrigin-Name: fdda76cfb01bf2b19522ac4558b443634d28a69b0828677c42682b645eae1f3b
2019-12-12 22:11:33 +00:00
numist
1b47c9c98e Reduce the number of call sites to dbMallocRawFinish in the case where n > lookaside.sz
FossilOrigin-Name: e392e7f22861ce4b66e4bf84b59c8fd38568fc241a699e001f47fd82011f4d28
2019-12-12 20:58:32 +00:00
numist
c947d6a4dc Fix an issue where malloc could be used to fulfill a small allocation when a large lookaside slot could have beeen used instead.
FossilOrigin-Name: 611020e3378f4c81c277cccd84807ae51a816bbab6c3d887c91c5e5af3b5225f
2019-12-12 20:39:47 +00:00
drh
41cee66848 Change the name of the Expr.a.zName field to zEName, so that it has a name
that is distinct from other fields and variables and is hence easier to
grep for.

FossilOrigin-Name: d3783357f8fa76c42a86f12b214522f0388c37773c36ab8c5ce0623abbc4436a
2019-12-12 20:22:34 +00:00
drh
0225d819c4 Change the size of a mini-lookaside allocation to a macro (MINI_SZ) rather
than a magic number (128).

FossilOrigin-Name: 5e1949bca998f3c8c23a8ebf01c7a2e7a2af1fdad43886271e1fe0f25411551d
2019-12-12 17:17:24 +00:00
drh
20d6c1fe1b Merge enhancements from trunk.
FossilOrigin-Name: 6cb053f99b5be2ecc30e0733d8f1e4f2a89f642656d3883fc0c867b10a87ba6b
2019-12-12 16:49:10 +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
numist
115d663c05 More efficient implementation of a lookaside allocator that supports mini (in this case, harcoded to 128B) slots.
FossilOrigin-Name: b02fdc09c838f355d9efce57f817d6a86153153b4a1f2b763914f4aaa34cb76e
2019-12-12 02:50:07 +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
drh
61cb4ed7f1 Add comments in the parse.sql file to help demonstrate how rules are
encoded.

FossilOrigin-Name: 2c4f714892327a1a9a303267b1f9685e310cca5dcea9c61287d95e26291b0506
2019-11-29 13:01:57 +00:00
drh
1417c2f77f Fix the parse.sql output file so that it is readable into a database where
foreign keys are enforced.

FossilOrigin-Name: 3a82c554c3bde4640df6865686f8f70e2c1e07c581fed4772b6b0a8ec1b10bb6
2019-11-29 12:51:00 +00:00
drh
2ecf928ea9 More details on the comment justifying the aleged data race in the WAL-mode
checkpoint logic.

FossilOrigin-Name: 0fab65c79f675c825ed7e85c82b65ce6f990c9d0796ebb3886942d241df7b268
2019-11-27 20:40:44 +00:00
drh
2bbcaee833 Fix various documentation typos suggested by Mark Benningfield.
No changes to code.

FossilOrigin-Name: 08f09dc4f986a27f4e4e69f8226dbfaf0cfe1269cefc2830bf0fbef7b9bbda48
2019-11-26 14:24:12 +00:00
drh
51690f26bc Fix to check-in [5d9a369301a65f32] so that it compiles without SQLITE_DEBUG.
FossilOrigin-Name: fefe2d046725254367f9f82a8c8cb137e8b75dbbf4bc48debf0649479ff2f0c2
2019-11-26 11:10:59 +00:00
drh
fe03dac236 Add the new -S option to the lemon parser generator to cause it to output
SQL that describes the input grammar.

FossilOrigin-Name: 4dbd398d640852d4a696d68c72ee039968023d402a8053b5e6b4ef1d75e982a8
2019-11-26 02:22:39 +00:00
dan
597f1eb195 Fix an assert() in fts3 that could fail due to corrupt database records.
FossilOrigin-Name: 5d9a369301a65f320a0696fcf1f062ca5976ef34350590c07aecf5335c66d872
2019-11-26 02:03:16 +00:00
dan
baa3458920 Modify journal3.test so that it can handle Tcl command "file attr <file> -perm" returning octal values in either "00755" or "0o755" format.
FossilOrigin-Name: b0b655625cf491c832a259d29a67660b8d5943c201617900a83d0660b2673377
2019-11-25 04:15:33 +00:00
mistachkin
fe293347ac Minor enhancements to the TclKit download tool.
FossilOrigin-Name: 75e31b1d56781fc4d28aea6c7f1393a18fd34870a5beb92df81c088d61351b4a
2019-11-25 00:07:03 +00:00
drh
a2f142d079 Abort the window function tree rewrite early following an OOM.
FossilOrigin-Name: d66f95a51530259ab48f78c9f91acc38055caf338b6fee846b99a8c077466e95
2019-11-23 16:34:40 +00:00
dan
62be2dc753 Avoid evaluating PARTITION BY or ORDER BY expressions multiple times for window function queries that use multiple window functions with the same window-definition.
FossilOrigin-Name: 57070c68bbe15fc1d19a765182432e844c082909bdbc63b58fd86b96e2c521dd
2019-11-23 15:10:28 +00:00
drh
0f31327eee Enhance the path arguments in JSON functions to access "#-N" array indexes.
FossilOrigin-Name: ffeec62cb5223ae70bc1889df4c0b241f5d17b1a10156362ca59953028741480
2019-11-23 08:51:21 +00:00
dan
7e88d6364c Fix a memory leak in fts5 error handling code.
FossilOrigin-Name: de6637e15d95b7aee2caea8b8d5b9865f276cbbf152ecf0401c4c7bfdf6dee6f
2019-11-23 08:36:35 +00:00
drh
5281864f0c Extend the json-path mechanism with array indexes of the form "#" or "#-n" for
some positive number "n", to reference the end of an array.

FossilOrigin-Name: 35ed68a651f4cf8740597433b0f1c3b345841868022e0904e9f342840ba0e502
2019-11-22 17:37:56 +00:00
drh
22de8357df Fix a harmless compiler warning.
FossilOrigin-Name: 34343c4b0657767f2676a2a9feb670cf000824e3eadfb1a6d87b57404191d8f9
2019-11-22 11:49:39 +00:00
drh
ec123e1301 Fix an indentation error and improve the placement of an assert() based
on a tweet from Yuri Kotov.

FossilOrigin-Name: e6314e386c6877c669bd32788d3886253b0a187bee2c3889f4eaba219f5e52c7
2019-11-22 11:47:04 +00:00
drh
73bacb7f93 Add more test cases from Yongheng Chen and Rui Zhong.
FossilOrigin-Name: f24e6ca4f23008212ec05cace9202dbeb37ee34530ead91fac2f5e3eac7f6347
2019-11-22 11:38:40 +00:00
dan
e59c562b3f Fix a crash that could occur if a sub-select that uses both DISTINCT and window functions also used an ORDER BY that is the same as its select list.
FossilOrigin-Name: bcdd66c1691955c697f3d756c2b035acfe98f6aad72e90b0021bab6e9023b3ba
2019-11-22 10:14:01 +00:00
drh
c398c65bee Revise the SQLITE_OPEN_NOFOLLOW so that it actually uses O_NOFOLLOW in the
open() system call.  This backs out the SQLITE_ACCESS_SYMLINK value but adds
the new SQLITE_OK_SYMLINK return code from the xFullPathname method of 
sqlite3_vfs when that routine resolves symbolic links. O_NOFOLLOW is always
included in open() system calls for journal files.

FossilOrigin-Name: 6a64fb6a2da6c98f1e87b55ad5689967e1db4eae2e08345471d95e28cd567e0f
2019-11-22 00:42:01 +00:00
drh
cd30064bd5 Add all fuzz-test cases received from Yongheng Chen and Rui Zhong. Also
fix a minor problem in gencol1.test cases.

FossilOrigin-Name: ac080432b480062507452d3cdbe6c0f759e6f95b65d9862e0462017405ab2b8e
2019-11-21 20:24:04 +00:00
drh
7dc76d8ba0 Fix an out-of-bounds array reference in the generated column logic.
Problem discovered by valgrind.

FossilOrigin-Name: a0ab42f779b9a96f4e43879210dfaba8fa593de77fc0ec0e2e6f116d9301ea59
2019-11-21 20:10:31 +00:00
drh
522ebfa7ce Whenever a generated column is used, assume that all columns are used.
FossilOrigin-Name: 6601da58032d18ae00b466c0f2077fb2b1ecd84225b56e1787724bea478eedc9
2019-11-21 19:37:00 +00:00
drh
57f7ece784 Fix a problem that comes up when using generated columns that evaluate to a
constant in an index and then making use of that index in a join.

FossilOrigin-Name: 8b12e95fec7ce6e0de82a04ca3dfcf1a8e62e233b7382aa28a8a9be6e862b1af
2019-11-21 18:28:44 +00:00
dan
9c9c70920b Fix a recently introduced memory leak in the test code in test_vfs.c.
FossilOrigin-Name: 2d53a30cc23e53033af8e8666457654db5dcc453ed6cd176ce1d0bff4f528159
2019-11-21 17:14:55 +00:00
dan
6637332988 Prevent direct and indirect recursive content= options in fts3/4 and fts5.
FossilOrigin-Name: 2eb997327c2c369c10b7835be80112d77cb2a7cfa9fe4d564042984c21d94698
2019-11-21 14:20:59 +00:00
dan
83420823af Fix a use-after-free problem in the test suite. No changes to production code.
FossilOrigin-Name: 0d1055a5da8274a59f35170b1f9469597ce4c5a4c5e851a1b81d3be2ccd32871
2019-11-20 16:10:40 +00:00
dan
70d1a1a3ed Further improve detection of corrupt records in fts3.
FossilOrigin-Name: a0f6d526baecd061a5e2bec5eb698fb5dfb10122ac79c853d7b3f4a48bc9f49b
2019-11-20 13:31:52 +00:00
drh
594b124f21 Changes to extensions and test logic so that the build works with gcc
and with -std=iso9899:1999

FossilOrigin-Name: 2575a68c3965e72f2ab211d933012442755afe6a9b7de9e9e50cdd2155fd1ec8
2019-11-20 12:07:40 +00:00
drh
cde342df70 Enhancements to DBSTAT: (1) Make name=? queries efficient. (2) Add the
ability to aggregate results across each individual btree using the
aggregate=TRUE constraint in the WHERE clause.

FossilOrigin-Name: a48f6e17599d7ec794cfcd60858d6a69cf05caaae9321048b111fedd86a3b5b2
2019-11-19 21:22:16 +00:00
drh
012b15e2d7 Get the aggregate=TRUE feature working on the DBSTAT virtual table.
FossilOrigin-Name: 16fef3db063830884de46d53a289f637a7204fe84fcdee7ea81dbb8bca578952
2019-11-19 18:48:11 +00:00
drh
ad84bd849e Begin an enhancement effort for the built-in DBSTAT virtual table.
FossilOrigin-Name: 9b5722f0fe666b99677e5f333dd8413aefb9ace7a461d74f6558f0ac53768719
2019-11-19 14:01:51 +00:00
mistachkin
4a4c1bf856 Make the result of sqlite3_normalized_sql() survive its statement being reprepared.
FossilOrigin-Name: 4330f0795dbc2ab41dddd41d5979331fb9b78c477c66367c4be52f929531a45f
2019-11-19 00:13:42 +00:00
mistachkin
3c161e07af Add support for the SQLITE_ACCESS_SYMLINK flag in the Win32 VFS.
FossilOrigin-Name: 175c15008e9f19b8f6762c2fe4a545735128765081980eed01d5e46ca4acb500
2019-11-18 23:48:03 +00:00
mistachkin
dc96192eef Ensure all file names passed to the VFS layer are double-zero terminated.
FossilOrigin-Name: 251230cf43c591cf49cf9d2f392581c57d334b791bc3407814d216b5999c32f4
2019-11-18 22:34:07 +00:00
drh
3c904885b1 In the SQLITE_OPEN_NOFOLLOW processing, distinguish between an I/O error
on the xAccess() call and an actual symlink encounter.

FossilOrigin-Name: 2e98b42fcb7bc38e22808a9dc1d7a4231ed08ffa97c9f08f33e6e8cd8726856c
2019-11-18 18:43:19 +00:00
drh
0933aad72c Add support for SQLITE_OPEN_NOFOLLOW.
FossilOrigin-Name: cb79c828496a703f1410f61458ebc1e15a92a63412b36f51945b2b5a32ec6e88
2019-11-18 17:46:38 +00:00
drh
804725a6b9 Improvements to detection of corruption in the %_stat shadow table of FTS4.
FossilOrigin-Name: 6b67eba54e7b4887a8cdab7537b12a95e9f17bcdaa0b423af5ed5bd91f69f2c6
2019-11-18 14:04:21 +00:00
drh
13a8f203d9 Further improvements to shadow table corruption detection in FTS3.
FossilOrigin-Name: e35d8c76aae59f57cc5193f79b21b4298029bea78e1aab7af67432162ce63e00
2019-11-18 12:04:17 +00:00
drh
3e72bdb5fe Detect and prevent infinite recursion in fts3SelectLeaf() due to a
malformed FTS3 btree.

FossilOrigin-Name: dfcf081d842629a0b177be7eb2eb8ce719324068991040a581e33ea1d5db3d27
2019-11-18 11:14:59 +00:00
drh
19d4175d65 Improved detection of corruption in the %_stat table of FTS4.
Chromium ticket 1025467.

FossilOrigin-Name: 10f8a3b718e0f47be528fba086c318e1dfe18ead383d01cfa24dedabad41e0a2
2019-11-18 10:37:57 +00:00
drh
ac801803a5 Fix an assert that can fail if the schema is corrupt.
FossilOrigin-Name: ed57c48e4bb337810521bda2da79614313e4835a317ca4eadb52bd67e4eadf98
2019-11-17 11:47:50 +00:00
drh
feb5dcf1a6 Better detection of corruption in the %_stat and %_docsize shadow tables
of FTS3.

FossilOrigin-Name: 1e449687881f4d388e54a0e51bcabba41ab10cf7e596ff65e31e88a23c70d497
2019-11-17 02:41:06 +00:00
drh
fd6bf04bba Remove a reachable NEVER() in FTS3.
FossilOrigin-Name: 8bd75bf636f72f32d66c6c38e1918f27daf2f13290f00a001f41d50838bbda47
2019-11-17 00:08:24 +00:00
drh
c72f2fb7fe More improvements to shadow table corruption detection in FTS3.
FossilOrigin-Name: 51525f9c3235967bc00a090e84c70a6400698c897aa4742e817121c725b8c99d
2019-11-16 23:47:40 +00:00
drh
94febb3a77 Improved detection of corrupt shadow tables in FTS3. Enable the debugging
special-inserts for FTS3 for both SQLITE_DEBUG and SQLITE_TEST.

FossilOrigin-Name: 04b2873be5aedeb1c4325cf36c4b5d180f929a641caf1e3829c03778adb29c8e
2019-11-16 21:40:49 +00:00
drh
3a5f9bc49c More restrictions on changes to shadow tables when in defensive mode.
FossilOrigin-Name: bae76a5c40703871e5ce4cd23d6fae5a3836606f524a63b01ac828c7a602c5e9
2019-11-16 16:54:53 +00:00
drh
527cbd4a10 Do not allow CREATE TABLE or CREATE VIEW of an object with a name that looks
like a shadow table name.

FossilOrigin-Name: 6aef58b629d89955f85f65191ba2be67b2adfac4f0327fe9a7141cb2705dbc00
2019-11-16 14:15:19 +00:00
drh
070ae3beea Break out the test for writable shadow tables into a separate subroutine.
FossilOrigin-Name: 8ad34d36a141fa8f5d9bd784dfeb892c983897a6dc6b867607cc668508acf944
2019-11-16 13:51:31 +00:00
drh
d0c51d1a04 Do not allow shadow tables to be dropped in defensive mode.
FossilOrigin-Name: 70390bbca49e706649ca5b7c031f0baf416fc38798c17e5f3b73746b3e66e3b5
2019-11-16 12:04:38 +00:00
drh
47bcc34271 Fix a potential NULL pointer dereference on a RENAME TABLE that references
a VIEW with a logic error in a window function in the ORDER BY clause.

FossilOrigin-Name: 0adb273f7e7671efb0e0a1619887e369500dfd2db7ef1b1e125c2414ea96e96f
2019-11-16 11:33:39 +00:00
drh
5710f1ad48 Modify three test cases so that they work even with unusual versions of the
library printf().

FossilOrigin-Name: 8f4a3750b7d272daf96831655ffee80d457875ee121fc4537008046b9a00d0e7
2019-11-15 21:16:34 +00:00
drh
8103a03607 Fix table-valued functions so that they will work as the right table
in a LEFT JOIN.  Ticket [2ae0c599b735d59e]

FossilOrigin-Name: 2c35d3f67b67a53ead08b1c395e7ca8e5bf65f94a5a962a0562994a3c66c95d9
2019-11-15 00:52:13 +00:00
drh
195a843691 Add support for the sqlite3_hard_heap_limit64() interface and the
hard_heap_limit pragma.

FossilOrigin-Name: 6399c47ea89c5766274bd6abdc9b6a85fe5b7f6c1078972c2f58e624bae59b7c
2019-11-14 18:07:28 +00:00
drh
31999c5cac Fix a bug in the hard_heap_limit pragma so that it returns the new value of
the hard_heap_limit, not the soft_heap_limit.  Change SQLITE_MAX_MEMORY so
that it works by setting the default hard_heap_limit value.

FossilOrigin-Name: 33fd0c3abcad5555a150990a22d9c1bab99e79be01143fccb9fafc9b52cf92c8
2019-11-14 17:46:32 +00:00
drh
803f06bf62 Merge recent enhancements from trunk.
FossilOrigin-Name: b8a631fd30d0732505679230684b3362c965438197a2b11518f01a77599c9202
2019-11-14 15:21:15 +00:00
drh
39d1a2a100 Minor documentation enhancements. No changes to code.
FossilOrigin-Name: 6153f3aada0cc9c5e773753797892ee78b518b0d76568382f5fbc9ee960f814c
2019-11-14 15:10:48 +00:00
drh
01d1801cab New test cases added to fuzzdata8.db.
FossilOrigin-Name: 5baffcda7d5a42a99fa905faa834f14b94b1e2a26b5221f15d8ae8f1f5e3236a
2019-11-14 13:57:15 +00:00
drh
ba01634cd3 Ensure that the same subquery does not go through the window-function rewrite
more than once, even when that subquery is part of a virtual table constraint
that lacks the omit flag.

FossilOrigin-Name: d0bc7db6b0a53edc04815622c46250d26f526f56e59f14875f4e18c75b49000d
2019-11-14 13:24:04 +00:00
mistachkin
b88eaf1619 Add header guard to the expert extension.
FossilOrigin-Name: 7e3151855fd4370fb7d4fff20516c2c2d1980134620df924106e6989bc130583
2019-11-13 18:50:36 +00:00
drh
dbf1c4ba8a Fix the sqlite3TreeView() output to consistently use a colon and not a
comma after the table number in the AST dumps.

FossilOrigin-Name: fa2416f623d83fe93253137302a74fcd6cdd041da337a0756df344d7d09a19f5
2019-11-13 16:50:06 +00:00
drh
d2c40e9310 For for the previous check-in: Always enable the nUri variable, even
when debugging is turned off.

FossilOrigin-Name: f84a15394c369cbdb6fba87c603a609722cf1f499626c7f20699060273ab5081
2019-11-12 16:21:27 +00:00
drh
746461f1b8 Ensure that the main filename and the journal filenames in the pager
object are all correctly double-zero terminated.

FossilOrigin-Name: df51ae19c1aa4c26f2dcd427eddc1c9cc24b698e1ab0a948b198a57432e25e1e
2019-11-12 14:43:47 +00:00
drh
4c8056079f Remove a harmless unused variable.
FossilOrigin-Name: 28091a48aa6994f8d7c142b5851bcd6b4e9a93a7bbef6c927a6182d24f3245b4
2019-11-12 03:45:23 +00:00
dan
a3b75e982a Remove an asm() block from build tool mksourceid.c, as it causes build failures on some systems and performance is not important at build-time.
FossilOrigin-Name: 8e100e6c35c30e0d7e4014b9435f81f9f61ddab2386dfe9a4218d8190a6da3be
2019-11-11 15:13:11 +00:00
drh
48eb03bd0e Proper surrogate pair decoding added to JSON functions. See the mailing list
bug report and [https://bugs.python.org/issue38749].  More test cases
needed here, but it seems to work so far.

FossilOrigin-Name: 51027f08c0478f1bf9d7545d9e268c772c0a5cd5dda4b03d78f16c7d94f2f50d
2019-11-10 11:09:06 +00:00
drh
9576802dba Remove an incorrect ALWAYS() macro.
FossilOrigin-Name: f7a74f89dbd58b47bbcb58ea2af71fbe1eb5ec2dbe36d90685c39cb28ecf5250
2019-11-10 10:08:03 +00:00
drh
12bf712707 Change the COLFLAG_NOTAVAIL bitmask so that it fits in the single-byte
Walker.eCode field.

FossilOrigin-Name: 53847f5c28bdecfbc7b08685d4dcd0565526f6191491b4827c3c966a4b8d4a85
2019-11-09 15:31:34 +00:00
drh
675f73bcab New dbsqlfuzz test cases added.
FossilOrigin-Name: 18c3a17dc8c07b12427e372ff86668d5bcb6b34d653c46c48561ed576acefa5b
2019-11-09 14:44:18 +00:00
drh
46a31cdf6b Make sure the WITH stack in the Parse object is disabled following an error.
FossilOrigin-Name: de6e6d6846d6a41c4821454dfdc042096234df753be08c5567b79fe535d9b6ea
2019-11-09 14:38:58 +00:00
drh
ff1032e5c2 When a virtual table reports orderByConsumed, that tells us nothing about
whether or not the SQLITE_DISTINCTBY constraint is met.
Fix for ticket [7e59041f9c4e5102].
Test cases in TH3.

FossilOrigin-Name: b59f94e4da9b1653f2004b214407a50340dd476b27e6ec7e29e501a95db9c963
2019-11-08 20:13:44 +00:00
drh
1e7c00e695 Fix the xferCompatibleIndex() function so that it recognizes that a PRIMARY KEY
index for a WITHOUT ROWID table is different from a UNIQUE constraint index
on the primary key.  Ticket [302027baf1374498]

FossilOrigin-Name: 34f64f11ca481996b1ff1686bdc5e278946635b6856cd1fe2355fce8e298e0f8
2019-11-07 14:51:24 +00:00
drh
4e8e533bf7 Restore generated column loop detection logic that was incorrectly removed
from the previous check-in [9e07b48934e9a972].  This fixes ticket
[299b50ba812d8e54]

FossilOrigin-Name: 104a2beb57037f9353ffa77096aae0eb64e4682e667f31623bfd3d064dd8d881
2019-11-07 02:32:54 +00:00
drh
dfa15270c4 Change the way generated columns are computed so that no column is computed
inside branch code that might not be taken.  Ticket [4fc08501f4e56692]

FossilOrigin-Name: 9e07b48934e9a972dcf62e3538b3b21ffa044c553feba0441675ac0bbe13bcb2
2019-11-06 22:19:07 +00:00
mistachkin
bde3a4f680 Minor simplification to the changes from check-in [36c11ad51f].
FossilOrigin-Name: 7bc8205dd9c1657c736a9c6a1a90dd9dad442accfbb77d296eaae2c09ab46bd1
2019-11-06 19:25:45 +00:00
drh
4fb24c82cd Fix the OP_DeferredSeek index-to-table column map in P4 so that it works
with generated columns.  Ticket [ce22a07731530118]

FossilOrigin-Name: 36c11ad51fe9ab1bde0b98d0ea9b8588e07d168cd8027486749372894941ad93
2019-11-06 17:31:18 +00:00
drh
b1129c423f Fix the handling of NOT NULL constraint violations for generated columns in
a REPLACE statement.  Ticket [2399f5986134f79c]

FossilOrigin-Name: 77b1c90add514050fe62f22751362fecacd99f9775346cffc60e09c326e64e10
2019-11-06 14:49:43 +00:00
drh
06fc24555f Changes an unreachable testcase() into an assert().
FossilOrigin-Name: 5710845b6314f924b490434b4446169f4bb50576aaa940472af68150db16e127
2019-11-04 12:49:15 +00:00
drh
6c68d7592f Fix a false-postive in the sqlite3ExprImpliesNonNullRow() decision routine,
that resulted in an incorrect LEFT JOIN strength reduction when the
WHERE clause contained a row-value comparison.
Ticket [02aa2bd02f97d0f2]

FossilOrigin-Name: ea20068e6d97c9349ebcc7d0a01e99ebf08c6f44363f71a0218a1abea209adc5
2019-11-04 02:05:52 +00:00
drh
db535390db The optimization of check-in [9b2879629c34fc0a] is incorrectly reasoned.
The WHERE clause of the partial index might not be true if the table of
the partial index is the right table of a left join.  So disable the
optimization in that case.  Ticket [623eff57e76d45f6]

FossilOrigin-Name: 3be19e1151af1850b65991edb82420f9412a7798dd756c86eaa9ffdde573263a
2019-11-03 00:07:41 +00:00
drh
0383661414 Fix a problem in VIEW creation that was introduced by the generated columns
feature.

FossilOrigin-Name: 9c795c4d2b042d2932774bd1274fa0167ca2dc9838e127e0cf31eb9273a32f2c
2019-11-02 17:59:10 +00:00
drh
089c4bc2e2 "STORED" is not actually a keyword. The parser looks for STORED as an
ordinary identifier.

FossilOrigin-Name: 167cd574d6a1d4fe2253f5bc5aaa7b031cbc82853e4d33b8d9b72eaf049003d4
2019-11-02 13:45:03 +00:00
drh
39b30a7d6b In sqlite3GenerateIndexKey(), do not attempt to reuse column values from
the previous index if the current index is a partial index as the partial
index test may have corrupted those values.  Ticket [a9efb42811fa41ee]

FossilOrigin-Name: 17e9f65814264de9c35bc5ba94e0a66fbbf1200c00d33ab9a19a0b6f92bc685a
2019-11-02 13:32:50 +00:00
drh
978256f3d8 Restore the on-line ".help" for the ".explain" command in the CLI.
FossilOrigin-Name: 28b8f1036d569bccce56b4e7042348024b5dd1ffa04850cbeddab1e35c49e5b7
2019-11-02 00:00:14 +00:00
drh
9c6a92982f Fix a harmless compiler warning.
FossilOrigin-Name: f0ebea35d9d6b69a7bb4242fb79ff3db4267e429855fa6969f9f52ffee1c7a99
2019-11-01 18:52:09 +00:00
drh
bc4974c81b The SET DEFAULT and SET NULL conflict resolution actions for foreign key
constraints should cause an error when they appear on a generated column.

FossilOrigin-Name: b47513d2b32b61ba42c1e9b59287d28f6fee231e6c65de2a3aa19effbbaf1e7f
2019-11-01 17:31:27 +00:00
drh
f2b9d7c605 Fix a potential use-after-free bug that follows an OOM error in code
added two days ago by check-in [84e02d773d60cffe].  Problem discovered
by OSSFuzz.

FossilOrigin-Name: 0a2eb949f8a759e5745d9468c8183d3c0b4b30e0fa2a14b3062620eb9e1d5c1d
2019-11-01 16:37:53 +00:00
drh
dc2e331ab2 Add another missing column number translation to the foreign key logic.
FossilOrigin-Name: 32df5edcfef2605009f45d6ef1b97c63a99df07c7b4e00dc70f93001cfb8d81f
2019-11-01 16:08:20 +00:00
drh
1a9082f6d7 Omit the optimization that reduces the column-count on rowid-table cursors
when the table has generated columns, because we do not know what columns the
generator expressions might try to access.

FossilOrigin-Name: e6c96ed91e7a96d2bd30ea9df132644ac02d5a321a62f81f8f3984a8e49ed94b
2019-11-01 15:19:24 +00:00
dan
b1c479b61d Fix an fts3 assert() that could fail when operating on a database containing corrupt records.
FossilOrigin-Name: 7c52f5478f9ecf5c078208759143ae9de43c1bf191dfcd74acb8bd169d4dc883
2019-11-01 13:37:26 +00:00
drh
f09a14fbc3 Add missing column translations to foreign key logic.
Ticket [c28a01da72f8957c]

FossilOrigin-Name: bc6a43e7ee6353b9ef3dea4309c77e170a1c798eefcfaa7636bf5a93e51c47ee
2019-11-01 12:14:30 +00:00
drh
e7d9814fe4 Fix a potential array bounds overflow in the mkkeywordhash.c code generator.
Also add marks to omit keywords specific to generated columns when building
with -DSQLITE_OMIT_GENERATED_COLUMNS.

FossilOrigin-Name: cc6a40818387f78f89499f09e3f1c4655c7396af1cba2596c7fb2f23f3e9755f
2019-11-01 10:49:15 +00:00
drh
bd0f0eb037 Slightly faster keyword hash table.
FossilOrigin-Name: f12e743e19a04ecbf7eb69b675082f2e4dda05b38cd81f6588a1ce95dfc57ada
2019-11-01 02:30:54 +00:00
drh
ff37c40787 Correctly generate pre-UPDATE content for virtual columns that are used
by foreign key constraints.  Ticket [b9befa4b83a660cc]

FossilOrigin-Name: 40d3282ec285d9f724f6548283f48b601510cf5284da17485723fd650a68f436
2019-10-31 20:54:20 +00:00
drh
29974f7b91 Add a few simple TCL test cases for generated columns. (Full test coverage
of the generated column logic is provided separately by TH3.)

FossilOrigin-Name: acedb5c7f7dc1d68bef62098d42ca59e1be7a5083bb03dc07c03b9f9d817158b
2019-10-31 17:13:17 +00:00
drh
04307c8a3f Ignore differences in Expr.op2 in sqlite3ExprCompare() in cases where it
does matter.  Ticket [1d2a8efc6c3a595a].

FossilOrigin-Name: 329820673a12ff6a6c8759f40989d4ccf272441064b0366a5f491695b55ad0e9
2019-10-31 13:16:26 +00:00
drh
d493353e99 Enhance the TreeView logic to show information about Expr.op2 for
FUNCTION and COLUMN nodes.

FossilOrigin-Name: aceeaf9e28767a0880a16872867a1f57bff163acd0f10d19d5688068077590fa
2019-10-31 12:30:38 +00:00
drh
20cee7d0bb Always disallow the use of non-deterministic functions in CHECK constraints,
even date/time functions that use the 'now' or similar keywords.  Provide
improved error messages when this requirement is not met.
Ticket [830277d9db6c3ba1]

FossilOrigin-Name: 2978b65ebe25eeabe543b67cb266308cceb20082a4ae71565d6d083d7c08bc9f
2019-10-30 18:50:08 +00:00
drh
920cf596e6 Simplify the bytecode generation for SQL function calls such that the
OP_Function or OP_PureFunc opcodes are coded directly, rather than using
the intermediate OP_Function0 or OP_PureFunc0 - opcodes that are now removed.

FossilOrigin-Name: 84e02d773d60cffe619104991d21d7f0c68616c0f6bb99686bf54f5306c756d0
2019-10-30 16:29:02 +00:00
drh
9ee94147f0 New tokens ALWAYS, GENERATED, and STORED used by generated columns should
all be fallback tokens.

FossilOrigin-Name: 13fe6978b7de208d2e27460d824f7fc778cf6ea0aabfe566b32bb410b8816f63
2019-10-30 13:00:23 +00:00
drh
66c48907a2 Remove the legacy_file_format PRAGMA. In its place, provide the
SQLITE_DBCONFIG_LEGACY_FILE_FORMAT option to sqlite3_db_config().
Fix for ticket [6484e6ce678fffab]

FossilOrigin-Name: 4d424f3047b48fc441475137f30a719d2f079390c86fe2617710ddfb05c5e240
2019-10-29 16:18:45 +00:00
drh
f4658b68fa Tighten the generated column requirement such that every table must have
at least one non-generated column.  Ticket [166347c6fc994155].

FossilOrigin-Name: 4fba090e678ef184736277c9ec9a9374c8bd4df4d41f51a3dc6818e2efcc103b
2019-10-29 03:39:17 +00:00
drh
b6d861e523 Add a missing translation from table column numbers to storage table numbers
while processing constraints on an UPDATE statement.
Ticket [9621dd78a024d07a]

FossilOrigin-Name: 361ea81ae8a13e7d2ec4c2412f30e049bb6ee320980d502c86bedc315cdd3bc0
2019-10-29 03:30:26 +00:00
drh
2c40a3eb35 Disallow tables that have only virtual columns.
FossilOrigin-Name: 591973217f1caf24cde91dc15b7edca2edda05dac8ae2b2cd8d71e7aa072f7d1
2019-10-29 01:26:24 +00:00
dan
9930cfe878 Fix a problem in fts3 causing it to report corruption if a doclist contains consectutive rowid entries that differ by more than 2^63.
FossilOrigin-Name: 0b0a3048f9df88bbc8979f2ac5247bee7d7bc1e585faca252610d2fcbe36d51d
2019-10-28 13:54:59 +00:00
drh
0f28e1bdd9 Remove a NEVER() comparison from sqlite3ExprCompare().
FossilOrigin-Name: f4285297e1e7ebef90bfc0f71402a4e1726d31bc15b69fec13a1f0d98fed1f08
2019-10-28 13:07:01 +00:00
drh
76baf799a2 ALWAYS macro added for coverage.
FossilOrigin-Name: a1e1ba9145049491c593ac70d9e05149662d34770129c270d702f284cd19a481
2019-10-28 04:20:28 +00:00
drh
a0e16a2261 Improved detection of attempts to use a generated column as part of the
primary key.  Ticket [91e86951016a6802]

FossilOrigin-Name: 6d1bbba9a004a2491c76b4a7d09edb9b738102c46fdcb3e0f7b22bffa719518e
2019-10-27 22:22:24 +00:00
drh
1231b4773d Remove code from the constraint checker that generates virtual column values
with the incorrect time.  Turns out the the regular code for all other
columns works correctly and so the incorrect special-case code is not
actually needed.  Fix for ticket [3ea175512444b0d1].

FossilOrigin-Name: 5b4c0f2ddc6f324e23bbde0ee3d1ab672cfe8ab5044c9b693f4c33cdd75c211e
2019-10-26 23:51:44 +00:00
drh
c34f05cca7 Remove redundant code resulting from a merge error on the previous check-in.
FossilOrigin-Name: 713fe86b8c9f3c9ef8af952019e99ba2f4741326226264de6a66baaeb1803d2a
2019-10-26 18:56:12 +00:00
drh
a88c8c1ae4 Add support for generated columns.
FossilOrigin-Name: b855acf1831943b3914491ed0bc333131321930cab480a5281012a3aebbba492
2019-10-26 18:47:47 +00:00
drh
cbda9c7ac7 Performance optimization on sqlite3GenerateConstraintChecks() - bypass the
loop that checks each column for NOT NULL constraints if it is known in
advance that the table has no NOT NULL constraints.

FossilOrigin-Name: e3c3f4d7872f431a95627d52553101388c1e39458cc7e7f93fc81255f49a89a5
2019-10-26 17:08:06 +00:00
drh
d3c468b758 Clarify some comments and add assert() and testcase() macros to the
replace-trigger recheck logic for ticket [c1e19e12046d23fe]

FossilOrigin-Name: 8c0042bd5ccd83f8794d19cbb1ec7564584f0dce54bfebc0ada00b836aca065f
2019-10-26 16:38:49 +00:00
drh
a015d3c82f Fix a problem in the legacy ".explain on" formatting when it is used on
a query with more than 8 output columns.

FossilOrigin-Name: 070b49825c5f87cce15be4b758f0dfdd65226ec379465ca527a18706a1f3b8f4
2019-10-26 16:02:34 +00:00
drh
166bc383e2 Minor changes to help ensure the pointer returned by sqlite3VdbeGetOp() is
not used after it becomes invalid.

FossilOrigin-Name: 346bdd49fb93aa58e8bd14250974d8c0c32cc7e8317c8b12da1fa44db10d8a3a
2019-10-26 15:40:17 +00:00
drh
d901b168b5 Overnight, OSSFuzz helpfully pointed out a potential use-after-free bug in
yesterdays changes, involving continued use of a pointer after the memory
pointed to had been realloc()-ed.  Thanks Google.

FossilOrigin-Name: c422afb507dc875751e6a72e4ba5f4f0793097c0de4533c1600311f689e76ed7
2019-10-26 12:27:55 +00:00
drh
0660884ea0 Add missing VdbeCoverage() macro. Fix an off-by-one error in partial index
handling.  New test cases.  Ticket [c1e19e12046d23fe]

FossilOrigin-Name: 41cc8e3dab998f7efc898d18837ca7fdac94ea3f89954990c5231456bf725fee
2019-10-26 01:43:14 +00:00
drh
a407eccb61 If replace triggers are run during uniqueness checking, then rerun all
uniqueness checks a second time using the ABORT algorithm.
Fix for ticket [c1e19e12046d23fe]

FossilOrigin-Name: fbac0c65d8464b126d385262d176864add55452ec9e3d5eb76ffee06e820cb9c
2019-10-26 00:04:21 +00:00
drh
db561bceda Performance optimization in sqlite3BtreeCursor().
FossilOrigin-Name: ea068b099c96b8b9526114732d2a6be186cf381b7329d102778ad25b95510c9e
2019-10-25 14:46:05 +00:00
drh
1b22c1b816 Merge fixes from trunk.
FossilOrigin-Name: 4ec57d88415fa4ea2e99d4a5671074ec6829d6824bc8509d5ae9c978d47d1419
2019-10-24 23:43:32 +00:00
drh
4485ac1a25 The previous fix was incomplete. It is also necessary to disable the
Expr.y.pTab field when making the translation.

FossilOrigin-Name: b99d5701312f7472e6b606bd824f9273617e2655920485bf50aa96d408064721
2019-10-24 21:02:06 +00:00
dan
ef2df8f343 In fts5, fix a case of overreading a buffer by 1 byte when counting characters in malformed utf-8. Fix for [dd1f67bf].
FossilOrigin-Name: 8d964e1c21d4cea699023e02b0616a75c5859dd083c9365cdcbc0676ebbdaae4
2019-10-24 20:35:27 +00:00
drh
c7476735c9 Fix handling of covering indexes that use virtual columns.
FossilOrigin-Name: e0f7e321eca91c49102649f70728de69347cbd7b16599b854203c24cfdc348e6
2019-10-24 20:29:25 +00:00
drh
06baba54b4 Correction to check-in [bec5b6d4d083556d] so that it detects *all*
triggers that might perturb the insertion cursor.
Ticket [50c09fc2cf0d91ce].

FossilOrigin-Name: 521f1d36282549488a47a434484a24924ee970d29f05a8ae499b7d536bcd692b
2019-10-24 19:35:26 +00:00
drh
035f6d909f Do not allow ALTER TABLE ADD COLUMN for a STORED column.
FossilOrigin-Name: 42fc08bc1528a34a603c2c085b515766a8d33ae7ea0350a52b0ca24b94ebcbc5
2019-10-24 01:04:10 +00:00