Commit Graph

21596 Commits

Author SHA1 Message Date
drh
3aef2fb1b4 Have the OP_ReleaseReg opcode also invalidate the registers if P5 is non-zero.
FossilOrigin-Name: 937be22106f7e3f08712febd342d6cb81d129f2d5ab24ce80b3a5c3f9bbde54e
2020-01-02 17:46:02 +00:00
dan
9f3e6fadde Handle blobs that are the return values of functions being cast to text in utf16 databases in the same way as blobs read directly from the database. Fix for [771fe617].
FossilOrigin-Name: e782096aa06fcf410c3a0a6ee26a9e4f44333da39b28b2efe675814a8652911a
2020-01-02 16:24:22 +00:00
drh
4cbd847a91 Fix the OP_Move opcode so that it correctly manages dependency tracking.
This change impacts debugging builds only.

FossilOrigin-Name: 5377add4b8af8c52d0a32f5273835ac6bdc42cfb2a95ffcb335b987437a91aa6
2020-01-02 15:02:08 +00:00
drh
22e95fbd74 Enhancements to aid testing and debugging:
In PRAGMA vdbe_trace=on output, show pScopyFrom dependencies on register
values.  Add the sqlite3VdbeRegisterDump() procedure, callable from a
debugger, that shows the values of all registers.  Pass the VDBE pointer
into test_trace_breakpoint() so that sqlite3VdbeRegisterDump() is callable
from the breakpoint.

FossilOrigin-Name: 9886cb4b7987f720aa9d701222ab0987caa0ab8c5d216cb6e523c4a45366dfe5
2020-01-02 14:42:42 +00:00
drh
52f11b885a Add the test_trace_breakpoint() subroutine that is invoked after each
instruction is printed while running PRAGMA vdbe_trace=on.  Only works for
SQLITE_DEBUG builds.  Also add parameters "pc" and "pOp" to 
test_addop_breakpoint() to make it easier to set conditionals.

FossilOrigin-Name: 49a6368c384178653cb3ccb58cc8eff93327c16929bf79eeefeb13a4ce897153
2020-01-02 13:26:49 +00:00
drh
629b88c683 Use OP_Copy instead of OP_SCopy to move the results of a scalar subquery.
FossilOrigin-Name: 435c272dcf6ed5f3acb564b8f959557145f117b869547b670258cf5a1908ab6b
2020-01-02 02:50:45 +00:00
drh
36e678bc39 The sqlite3WhereEnd() call now unwinds all Expr modifications made by the
sqlite3WhereBegin().

FossilOrigin-Name: 7bfd42f1dc0c94f9bb74516e62fec8e39c20f4749f4e0972f66c2886d3c64f73
2020-01-02 00:45:38 +00:00
drh
2a83c10072 Provide the -DSQLITE_ENABLE_INTERNAL_FUNCTIONS=1 compile-time option. Fix
the ".testctrl internal_function" command in the CLI so that it does not
signal an error on a valid input.

FossilOrigin-Name: 8ee2ce92c082771675d0e8be597043cf9f0fd4f8a73d6a1498bf8743d6b3904a
2020-01-01 23:02:35 +00:00
drh
fc705da15d When generating code for a subquery, make a copy of the Select object and
generate the code out of the copy, in case the code generator makes
modifications to expression and the Select object needs to be reused.

FossilOrigin-Name: 4edddcc0bc8d71e9b8abac67bc3766f1d9143dddd1f59264859ce65e5aa9b8c6
2020-01-01 21:14:30 +00:00
dan
4ea562ee70 Ensure that when code for a scalar SELECT featuring window functions is generated more than once by the planner, separate ephemeral tables are opened for each instance.
FossilOrigin-Name: ce1417325273aba866767349b55d9bbfb61a08e716bebda2122918a9657ee38c
2020-01-01 20:17:15 +00:00
drh
aef8167421 Fix the sqlite3ExprImpliesNonNullRow() routine so that it correctly
handles a numeric comparison of two AND subexpressions.

FossilOrigin-Name: 07e504d5174a1a8b1aa05ec5b44ac81ab3ea706c5a098caa88deb3d489cec8fb
2020-01-01 16:43:41 +00:00
drh
171c50ec38 New test-only SQL functions: implies_nonnull_row(), expr_compare(), and
expr_implies_expr().  The SQLITE_TESTCTRL_INTERNAL_FUNCTIONS test-control
is modified to toggle internal function access on and off for a single
database connection.

FossilOrigin-Name: 473892a8eceacf24d57fd0c72ff2a0b8be4e0d75e0af7a30bdb24fbc3b453601
2020-01-01 15:43:30 +00:00
drh
25c4296bd9 Factor out code generation for in-line SQL functions into a separate routine
inside of expr.c.

FossilOrigin-Name: 586a65a28fc6cac77309612abc32a2e1017c65e0387f9f438f5d8ac8406da8eb
2020-01-01 13:55:08 +00:00
drh
6d67aff0e3 Issue OP_ReleaseReg opcodes against the array of registers used to compute
index records after the index record has been computed.

FossilOrigin-Name: e3330861b4deab7c7cc09ad8b936d633c600b9fb4e274801efeaaf94e5c860b4
2020-01-01 01:26:05 +00:00
drh
51676fab72 Remove an incorrect assert() statement. Ticket [46fcd700b855e6d1]
FossilOrigin-Name: eca7ec9cda4606c4104bcb8da315070b615713db9f3444579c6a3e96b0aad02f
2019-12-31 23:17:35 +00:00
drh
b945bcdaf1 Experimental branch with new sqlite3_db_config() options that could possible
enhance security for applications reading potentially compromised database
files.

FossilOrigin-Name: 96a2db2612f2e47bbec0e374a242820c88f03c42ccbf8467abccaef41469bae2
2019-12-31 22:52:10 +00:00
drh
64de2a5f7b Also set the SQLITE_DIRECTONLY flag on the load_extension() function.
FossilOrigin-Name: 3bd095a53119c368fe30e539983588b27957203344cf427405b9a64784b8eba7
2019-12-31 18:39:23 +00:00
drh
1e732787da Set the SQLITE_DIRECTONLY flag on the fts3_tokenizer() function of FTS3,
thus preventing that function from being called from within a trigger or
view.

FossilOrigin-Name: f3171dc22e4d3a40ca17fe609391d92fc6a997b775bfefa5947aec69c889aa73
2019-12-31 18:12:36 +00:00
drh
cf014f6cbd Refactor names. Use "small" instead of "mini" to describe the smaller
of the two lookaside memory allocation sizes.

FossilOrigin-Name: 88d244983854cdc1a369c5df09ae00f1098784db768ba4e17b963d187dcb1009
2019-12-31 15:12:34 +00:00
drh
5f6a2ed7f2 Merge recent enhancements from trunk.
FossilOrigin-Name: 39d55579376906f212271ce9b2d367e3ad029fb173f22c7253312b467970208a
2019-12-31 14:49:10 +00:00
drh
02ff747bc0 The OP_ResultRow opcode releases the SCopy dependences on all its registers,
as the values in those registers will not be reused.

FossilOrigin-Name: 1dc83c5d54ca2890112e735e336c209adb8d067d2f647e9f8ae5d58f84a52461
2019-12-31 12:18:24 +00:00
drh
70d6b8327a Back out the NEVER() from check-in [40d10e7aad5b8992] because it is reachable
after all. Ticket [892575cdba4e1e36]

FossilOrigin-Name: f481636f1a0333c6e98906e5d4433bf1d046380bc29c760e8e7e2c2b3530b956
2019-12-30 23:50:19 +00:00
drh
0b973c8bff Add an ALWAYS() to a conditional which is apparently always true.
FossilOrigin-Name: ea44c607b8038999a6bda4d761d95056aa4058d6c2891b7eee0715a50e703490
2019-12-30 23:41:59 +00:00
drh
2b173b93fc Put a NEVER() on a defensive branch.
FossilOrigin-Name: 40d10e7aad5b899206e45d1f8606470a90a07049e15d94c3811cfe695f3a402e
2019-12-30 20:42:53 +00:00
drh
8d95ed789e Fix a typo in a comment. No changes to code.
FossilOrigin-Name: d4813a8d813f234e819f8ebefbd3ff96d3d69593cc7d716cf0ad6c1a126da827
2019-12-30 20:42:17 +00:00
dan
9d41af23a4 Do not use HIDDEN columns for NATURAL joins. Fix for [7c0e06b16].
FossilOrigin-Name: ab09ef427181130be09a087b7e572ad4cfb6b3e1b459769ee5ebf046b3ead682
2019-12-30 14:32:27 +00:00
dan
2b6e670f73 In ALTER TABLE, rename columns and tables in expressions that are optimized out by the "AND 0" optimization. Doing this also fixes an otherwise harmless assert() failure.
FossilOrigin-Name: a9e0354c992b0287608ddd18fd35fe7e6102a8f293d6e6e1b3488644bcda8168
2019-12-30 06:55:31 +00:00
drh
7b14b65d20 Do not allow triggers that run as part of REPLACE conflict resolution
during an UPDATE to modify the the table being updated.  Otherwise, those
triggers might delete content out from under the update operation, leading
to all kinds of problems.  Ticket [314cc133e5ada126]

FossilOrigin-Name: db4b7e1dc399c1f16b827ac087aa37c0815f4b2f41f1ffad59963eead2ab5562
2019-12-29 22:08:20 +00:00
drh
be3da24134 Add the OP_FinishSeek opcode which completes an OP_DeferredSeek if the seek
has not already completed.  Also add the sqlite3WhereUsesDeferredSeek()
interface to the query planner.  The UPDATE implementation adds an
OP_FinishSeek before running the final OP_Insert if one is needed.
Ticket [ec8abb025e78f40c] and also an assertion fault reported by Yongheng.

FossilOrigin-Name: 21ef6e99331210b80fa7c71b4f02e8f768a748d01aef884368af2f6b51a067e0
2019-12-29 00:52:41 +00:00
dan
997d7434b7 Do not attempt to flatten compound sub-queries in a FROM clause into the parent if any component of the sub-query uses a window function.
FossilOrigin-Name: eeb76f621de2f930a548db0fbb9fe25b4479b73581826b8dfa2e63cd1f1ab783
2019-12-28 18:25:51 +00:00
dan
4adb1d0000 Change an assert() in where.c to a testcase() macro, since the condition may be false. This was a problem with the assert() only, there is no bug in release builds that omit assert().
FossilOrigin-Name: 82be135dee7ccfde5f8a67f3621b7ced449dce89bae9cadf025154a4de848c11
2019-12-28 18:08:39 +00:00
drh
a4b2df5ce2 Disable early coding of transitive constraints at the end of each loop in
the WHERE clause processing if the loop being coded is for a LEFT JOIN,
even if the loop is part of an OR-clause optimization for virtual tables.
Test cases in TH3.

FossilOrigin-Name: 9421b442cad9858ec21050c106aa935a1c0723ab08ef9a867a79638b040b6e68
2019-12-28 16:20:23 +00:00
dan
51f2b1719c Fix an instance where the planner might choose to use the OR-optimization when it adds no benefit. The same quirk causes an assert() to fail. This is not a bug in released versions - without the assert() the library still gets the right answer, it just does so less efficiently than it should.
FossilOrigin-Name: f4bed1d7af8a94c6facd567dec5afae8865a5ad76b8834493099e5e30bed1132
2019-12-28 15:24:02 +00:00
drh
f1bb31e219 Further improvements to .wheretrace during loop code generation.
FossilOrigin-Name: c4d5b75c9381255ec8d9a284eedb6b27be46ca868cae5985cf8a5769b15290c3
2019-12-28 14:33:26 +00:00
drh
118efd1626 New enhancements to .wheretrace. The 0x20000 flag shows the WHERE clause
before and after coding each loop.  The 0x800 flag shows status at the start
and at the end of each loop.  An extra "C" tag is shown on coded terms.

FossilOrigin-Name: 59cc46e5a6d8dbb030f27716ad5446ecccf81cf0cfff95338b9133777f2059e7
2019-12-28 14:07:22 +00:00
drh
cacdf20771 Expose some of the Where data structure debug printing routines to the
entire WHERE-clause processing module.

FossilOrigin-Name: 85e76887761b5d7e290fb2bac7f9121648f79d67fdd92f624d81632f28620518
2019-12-28 13:39:47 +00:00
drh
29368eabc5 Add the --enable-all option to the main configure script as a short-hand
to enable FTS4, FTS5, Geopoly/Rtree, JSON, and Sessions.  In the
amalgamation-autoconf, the --enable-rtree option (which is enabled by
default) also now activates Geopoly.

FossilOrigin-Name: 52ea0672d7494346c636cd7b05ca42161eb3b07d9378fa9959be9a11de87dbbb
2019-12-28 13:17:11 +00:00
drh
cfcf4de4a6 Simplifications to the initialization of the sqlite3_index_info structure
that is used to communicate with virtual table modules.  Avoid adding
unused constraints to the sqlite3_index_info structure.  Extra constraints
are harmless, but might be confusing to people trying to understand the code.

FossilOrigin-Name: 5e6357fc953a955d8ebb5c1fcd72e04e4ae5e8bf5941810015c2fbc50de70535
2019-12-28 13:01:52 +00:00
drh
6411d656aa If the ".wheretrace 0x10000" bit is set, print WhereTerm.prereqAll
and .prereqRight fields in the WhereTerm trace output.

FossilOrigin-Name: a4f330b133a36356681dce7d2a65d8ab792620494d6cd4ef4934a97cf3a8e6fc
2019-12-28 12:33:35 +00:00
drh
7505123fe5 Two new test cases added to test/fuzzdata8.db.
FossilOrigin-Name: 1be2c18f4021e1d0b8412ecb68a599475c717dd97c7db209fc4203358957fd70
2019-12-28 11:55:44 +00:00
dan
409f3370af Second attempt to fix a problem with unwinding the WITH stack of the Parse object following an error.
FossilOrigin-Name: 315d1f1a503e8c186739658c85b92fa3d12514e5baaa26925c85664b5e85d1c0
2019-12-28 09:08:27 +00:00
dan
43526f4ada Merge latest trunk changes with this branch.
FossilOrigin-Name: d693be375380fbfca426999a77eeecb8453fa77b77f608bfe266945dee1da41d
2019-12-28 08:33:46 +00:00
dan
5d59102a91 Fix an assert() failure in altertable3-22.4.
FossilOrigin-Name: c566a91d5c4290b0a491a01e85bf8f9fbebf2910e0d478bafc2d22da7f749cae
2019-12-28 08:26:47 +00:00
drh
9a1f2e4853 Fix a faulty assert() associated with query search limiting query plans.
FossilOrigin-Name: 0d743585c242ebd898b232f42937a2306752aaed0a6756705e3ef1cf7593aa97
2019-12-28 03:55:50 +00:00
drh
b97f3532f5 Convert an assert() back into a conditional. The conditional was converted
into an assert() by check-in [6ae4ad6ebee4db88] (2009-05-28) because we were
unable to find a test case for it.  Yongheng's fuzzer just now
found that test case.

FossilOrigin-Name: 4d0b9109f7a5312d4e136395e08b11dad64d746bc106ad44d47675e5b1dcb4ef
2019-12-28 02:40:49 +00:00
drh
d9670abb58 When an INSERT is receiving content from a SELECT, run an OP_ReleaseReg opcode
at the top of each iteration of the loop in order to prevent spurious
OP_SCopy misuse complaints.  Ticket [de4b04149b9fdeae]

FossilOrigin-Name: 6afadd3b3a40b0ef29fd14fb24c2a4b9479483e5f8b9125ce02d8daae662207f
2019-12-28 01:52:46 +00:00
drh
ad5f157791 Recompute the values for all generated columns after
NOT NULL ON CONFLICT REPLACE constraints fire.
Tickets [37823501c68a09f9] and [5fbc159eeb092130].

FossilOrigin-Name: 4cc12c18860bc4801a407cf45e88e23d3d40391f01a461fbac2cac5f102100e1
2019-12-28 00:36:51 +00:00
dan
a6c1a71cde Do not attempt to unwind the WITH stack in the Parse object following an error. This fixes a separate case to [de6e6d68].
FossilOrigin-Name: d29edef93451cc67a5d69c1cce1b1832d9ca8fff1f600afdd51338b74d077b92
2019-12-27 20:54:42 +00:00
dan
b4b3630657 Remove a NEVER() that is no longer true. Fix for [36ffedcb9].
FossilOrigin-Name: 597896ed0ae9e2960a8f39576bd7f77a11dccc1da84b6a44ebb5c38d90ebc330
2019-12-27 20:06:32 +00:00
dan
e3735bf466 Fix a problem involving window function aliases being referenced from sub-selects.
FossilOrigin-Name: e3b5fc05c00fc58be7a7c94ce1d97a5b05113f39aba03df64aab08364f85616b
2019-12-27 19:46:07 +00:00