drh
d875c7eefe
Do not allow an empty table bypass to jump outside of a right-join body
...
subroutine.
FossilOrigin-Name: 1549dcd2353903b70abadd428eeef971ab940df04fb05a6b83b04ee30932db6d
2022-04-18 10:26:50 +00:00
drh
d973268ccf
Fix the sqlite3SrcListAppendList() routine so that it correctly adds
...
the JT_LTORJ attribute to the first SrcItem, if needed.
FossilOrigin-Name: 07ed0dca310d828f9fe152efa8ee2a89202771a8f661afa1dbeee34aaabef67a
2022-04-18 10:09:29 +00:00
drh
abf86bd313
Leave sqlite3ProcessJoin() early if an OOM is encountered in the NATURAL
...
to USING converter. This avoids NULL pointer dereferences further along in
the code.
FossilOrigin-Name: 0ccb224e13ad44c7e1a3aa186821a929faabc0075fe15799476c00d9a92e9d91
2022-04-18 09:59:33 +00:00
drh
79a25ee021
Fix to the coalesce() function generation in the resolver.
...
FossilOrigin-Name: 584bd55e20669d09b7efe3429ba847c42c32fb1eb960784c4e0dedcd96899313
2022-04-18 00:57:11 +00:00
drh
d0453f7ec5
When converting a NATURAL JOIN into a JOIN USING, make sure to insert the
...
name correctly into the IdList even if it is a wierd quoted name.
FossilOrigin-Name: e62156b696f2496e2697cb3b46f136551b58644e2a5824aa3d759596694b2f4b
2022-04-18 00:04:15 +00:00
drh
a3e2518bb3
Fix to the logic that computes coalesc() functions to resolve USING terms.
...
FossilOrigin-Name: 20388548d868511f8c8437718985d75fe9801835811fec716f1700727b9aa367
2022-04-17 23:46:18 +00:00
drh
f68621fe83
Deal with OP_Return bypass in the RIGHT JOIN subroutine by adding extra
...
OP_Returns where needed.
FossilOrigin-Name: 71abe5641f599f27d1f0c800f6182e1168909f8aa99389b835b07d4b5f5483eb
2022-04-17 22:58:23 +00:00
drh
2bd9f44a18
Change OP_Return such that if P3 is 1, the Return is a no-op when the
...
P1 register contains a NULL.
FossilOrigin-Name: c90602328a4b26f06d76c5343d29ebb7a782186c86ea88f5965a41040cff5346
2022-04-17 20:30:52 +00:00
drh
fe14699765
Further improvements to USING() processing for RIGHT and FULL JOINs. All
...
currently known issues are now resolved. Performace is improved.
FossilOrigin-Name: 9fd3f22e2228dfba127f6ffe549109f3a4e910fa124adcc9c5483931bd6d5cd7
2022-04-17 18:46:17 +00:00
drh
6fda176ba6
New test cases, one of which is failing, indicating a bug that needs fixing.
...
FossilOrigin-Name: bd5fd68435ff068c18d7d46b33cf7591263a03c32a917a7df7c087b08c573cc8
2022-04-16 23:38:29 +00:00
drh
052953a4e6
Fix the USING to ON translation so that it works correctly for a sequence
...
of two or more joins where one of the joins to the right-hand side of the
list is a RIGHT or FULL JOIN.
FossilOrigin-Name: 9ffc2b231956cde1bc90519aa174b0e2dc30ef671ed745f4f3ffa9fbb7ffab4b
2022-04-16 22:57:41 +00:00
drh
fdc621aece
Since the query planner is unable to cope with a LEFT JOIN on the left-hand side
...
of a RIGHT JOIN, detect that situation early and raise a parsing error.
This is a temporary measure that needs to be fixed.
FossilOrigin-Name: 6d5d6e0403241c99ab4a47d7b6eedcd8ebc615a8ca8d66d7e81171f901b170d7
2022-04-16 19:13:16 +00:00
drh
cebc8009ed
Additional SELECT trace logic: Show the tree after result-set wildcard
...
expansion but before name resolution.
FossilOrigin-Name: a7babf75418adffa27dec7a9d382a60e1b9364fb51d72b0a10e2769b308b3c54
2022-04-16 18:33:22 +00:00
drh
977eef6cdc
New test cases. One of the new test cases shows a flaw in the base design
...
of RIGHT JOIN.
FossilOrigin-Name: 4c3ce6475a67b1e207a5b63d9e2d38ee5bc45c899ad00ee327f292bf59039b9c
2022-04-16 13:55:48 +00:00
drh
bdbda1eb1f
RIGHT JOIN USING now appears to work the same as PG-14. Legacy tests pass.
...
FossilOrigin-Name: 5bfb862419541de955dae35fc91f6e9fc70e2744bb786d49fa26bede80b9091d
2022-04-16 12:40:52 +00:00
drh
be60896485
Revamp the USING clause processing so that it works (mostly) with RIGHT
...
and FULL JOIN.
FossilOrigin-Name: 719c8d920b435b0f234d47467a2abe2941ab7d55ecca886e211cfce577ae648c
2022-04-15 19:53:35 +00:00
drh
e62d9149a6
Avoid deleting substructure of the Expr node in lookupName() until after
...
the error message is generated.
FossilOrigin-Name: b8e717663957dfd84e580bf21bc8e8881b33fdb94a2cc0c664a230e54d5e5076
2022-04-15 19:49:28 +00:00
drh
bb3c62a758
Progress toward a working USING for FULL JOIN.
...
FossilOrigin-Name: fed2646adecb0a05dd674dc1cd2c0ae205078fe552ba93b8d68891c728c67637
2022-04-15 19:27:02 +00:00
drh
4ce7bf9156
When expanding "*" in the result set of a SELECT, do not attach a table name
...
to columns that are in subsequent USING clauses.
FossilOrigin-Name: 91530990e018580ec5322ace6f0c369a32a3529a0bfb4defb25ca20223a2a80f
2022-04-15 18:30:48 +00:00
drh
22c4bc8991
The sqlite3ProcessJoin() routine converts a NATURAL JOIN into a JOIN USING so
...
that henceforth the NATURAL keyword can be ignored.
FossilOrigin-Name: 8378e1e0d289627fb294ccd3f5865ef49df3a42b8a5aa211e21be1b42d9da753
2022-04-15 17:08:40 +00:00
drh
a99e325468
Enhance the IdList object to exist in a single memory allocation (rather than
...
a separate allocate for the base object and the array of IDs). Also permit
an IdList object to store an Expr pointer together with each name.
FossilOrigin-Name: 40f3c95871e6f40f287ef2756abafb8fc56dffdd0af69436e5c7d8e95022d94e
2022-04-15 15:47:14 +00:00
drh
358424aeff
Add the "3" in the name of the sqlite3ProcessJoin() function.
...
FossilOrigin-Name: b925f72b6f679c61b0d6be16fabe64dc7605550b7bd86f35c586dcecd8217673
2022-04-15 15:15:01 +00:00
drh
a51379ad78
Record the three known big issues with the current RIGHT JOIN design in
...
the join8 test module, with tests that deliberately fail in order to remind
us to fix the issues.
FossilOrigin-Name: 2c4ee723f4d0591d09776adfb82246bfa89153ab390b8b3f1878d1cdc43d68c8
2022-04-14 20:43:22 +00:00
drh
79f60034ee
Another instance of indenting a subroutine.
...
FossilOrigin-Name: 73f4036b04798660b30e540cbab69420078df9fb62a6a39944e078c36272f905
2022-04-14 19:05:17 +00:00
drh
d549a702b3
Check for interrupts and invoke the progress handler following a Gosub
...
opcode, to avoid and recover from infinite subroutine loops.
FossilOrigin-Name: 647211e044a5856ceb6bf3e7b78e650fe7d81f8b7bf34568b99b346405ba520c
2022-04-14 18:19:06 +00:00
drh
2c31c00bfa
Rerun the subroutines that compute row-values if necessary from within
...
the RIGHT JOIN body subroutine.
FossilOrigin-Name: 9b9038bcd0ab5c4f01661456635526cef764f854ff24018a5e6e43825d07eb59
2022-04-14 16:34:07 +00:00
drh
37f5584a2f
Adjust the output formatting of bytecode listings so that subroutines used
...
to implement subqueries are indented one level.
FossilOrigin-Name: 079b7b125206fb295720612f4853a5b786ec431ab595d35407195844779c149d
2022-04-14 15:55:34 +00:00
drh
d345dcf39a
Disable autoindexing for the RIGHT JOIN loop.
...
FossilOrigin-Name: 402a89e33e39b00352dc9fb3301d03c6f75d8bb5c2ad540cd22506bff10b4d85
2022-04-14 14:58:50 +00:00
drh
375f182b1d
Adjust assert() statements to account for the new always-NULL cursor type
...
added by [4526c5d316508093].
FossilOrigin-Name: 7822faa48a058c0b0313b9241d290153fbe74ab84f58369a70014118a9085d1d
2022-04-14 14:40:29 +00:00
drh
c504f677b6
Previous check-in accidentally inverted a test on an assert(). Fix that.
...
FossilOrigin-Name: 5ec4f806c569428851b6f0159451aa3ed66b3bc61a845fd7c543cffb694b882d
2022-04-14 14:19:23 +00:00
drh
eab6c125bd
Fix assert() statements associated with artifical null-value cursors
...
created by RIGHT JOIN.
FossilOrigin-Name: f5bce5f152259767497ae6826c558003822d976b3f35f4d74edee59a3490efb2
2022-04-14 12:59:25 +00:00
drh
95b1036e9a
Fix a harmless (false-positive) unused variable compiler warning on MSVC.
...
FossilOrigin-Name: 63b04c63de680261a0d3eaf27154a1e8e77e3e166c3f2dbaea985603991c74f7
2022-04-13 19:00:57 +00:00
drh
b60d1fbe8e
Make the sqlite3TreeViewSrcList() routine a no-op if called with a
...
NULL SrcList object.
FossilOrigin-Name: 185d2720e7775e3060a1647353c10aada435244db53a0732ee786788a6ecae3f
2022-04-13 18:32:04 +00:00
drh
7c96039492
Fix an assert() in OP_Column so that it accounts for the new type of
...
pseudo-cursor that always returns NULL for any column.
FossilOrigin-Name: 371ddc97bef8e0d88ad965f00d27e010880174312ea36c4f1165dcf08441f40a
2022-04-13 18:20:23 +00:00
drh
3ac624344d
If the OP_NullRow opcode is given a cursor that has not yet been opened,
...
then go automatically open it to a special pseudo-cursor that allows returns
NULL for every column. Used by the new RIGHT JOIN implementation.
FossilOrigin-Name: 4526c5d316508093b7f3aeda1ce9d16ceb0be79842015a6d51f28c22b4473ca2
2022-04-13 17:41:03 +00:00
drh
f7ecd956ce
Move the explain comment for the RIGHT-JOIN post-processing loop to the
...
verify beginning of the loop - to make the start of the loop clearer to
human bytecode readers.
FossilOrigin-Name: 7ed2a271e6fcbb5e69a7f3a88d3f45fe6318819c0cc6a0dcc06c3dae5aa1503f
2022-04-13 16:46:35 +00:00
drh
94e615a6ac
Add support for RIGHT and FULL OUTER JOINs.
...
FossilOrigin-Name: fa9d206f904280e3eafc6f4ba6c0c7325948364c62eeeb9f0fdc5825d622ec35
2022-04-13 12:34:54 +00:00
drh
12c35ec322
The rows of a RIGHT JOIN might come out in any arbitrary order. So disable
...
the ORDER-BY/GROUP-BY optimizations if a RIGHT JOIN is involved.
FossilOrigin-Name: d168f245ecf497368feea4697769930c00420ef47a584904dac85371b61fb78a
2022-04-13 12:12:01 +00:00
drh
3b79f7580a
Fix an assert() in btree.c that might not be true for a corrupt database file.
...
FossilOrigin-Name: dbd8e2e46cfb2de0ebdbb62cda2fe669df3eda98f5d6112d541f581995b1361d
2022-04-13 10:49:50 +00:00
drh
146e64d2e4
Add missing VdbeCoverage() macros on new branch byte-code opcodes.
...
FossilOrigin-Name: 218c7167e562f5c327124f02a92de85079315320a221fb0508310d927596b14c
2022-04-13 01:52:32 +00:00
drh
f7309bce10
Ensure that the JT_LTORJ bit in the SrcItem.fg.jointype is preserved during
...
query flattening.
FossilOrigin-Name: 61259050152321bc57dbdfdc3edcabb4f18c021b1ee0491c1e04ae24c7a59d89
2022-04-12 20:20:54 +00:00
drh
0879d5f9e0
For the bad join type error message "unknown or unsupported join type"
...
remove the "or unsupported" clause, because we now support all valid join
types.
FossilOrigin-Name: ab0a0562dd3594cf50ee56f6b3a5847fa5dcadf69146d560e3e7a95651b8f405
2022-04-12 18:40:14 +00:00
drh
949e2ab49a
Factor out the RIGHT JOIN non-matched row loop from sqlite3WhereEnd(). This
...
reduces the register pressure on that routine and helps it to run faster
in the common case where there is no RIGHT JOIN.
FossilOrigin-Name: beeecf1604d4fb11e45058f48cb2289c6542e0bc218d63a245198113d8d5476b
2022-04-12 18:04:29 +00:00
drh
57d4b5bde1
Merge the latest enhancements from trunk into the right-join branch.
...
FossilOrigin-Name: b3e57ba120067c79e0398e39da9f00ecb11a5e18c36479da4c36a39e88a78a27
2022-04-12 17:43:30 +00:00
dan
6625d6d873
Earlier detection of corruption in balance_nonroot(). dbsqlfuzz 9191ade77ebd3b7a3356e074957aa85b0c669d14.
...
FossilOrigin-Name: bff4f083eb1c35544988493a5d73a42e646c4250b841f5aae38c2183f0867a0e
2022-04-12 17:02:27 +00:00
drh
61dac44eb9
The multi-index OR optimization does not work for RIGHT join, so disallow it.
...
FossilOrigin-Name: 34c2f7b237fa4e0e1cd94fb9c44ebe194b86b88dc575055cc46c7f3695d02756
2022-04-12 14:23:45 +00:00
drh
a70782407d
Always explicitly set each table cursor to NullRow before doing the RIGHT-JOIN
...
unmatched row pass. This is a cheap opcode, and it adds an extra layer of
defense against incorrect results.
FossilOrigin-Name: a3d14e61ca22167296fee125a3e9aa63413408955e03bb3f9d85fa9f22df1b79
2022-04-12 13:46:21 +00:00
dan
f7413d9acf
Modify utility function sqlite3SetString() so that it may be used safely on Parse.zErrMsg. Fuzzer test case "crash-1604e5d76c92574e21e437049dab9b672e06b767.txt".
...
FossilOrigin-Name: 09c5a4ec13b02efd6207e26dab7beaf184f0d8ccea0bd0dfe94fc803fe5636ce
2022-04-12 11:02:06 +00:00
drh
b087de063b
Fix RIGHT JOIN for virtual tables.
...
FossilOrigin-Name: 75a9116e98b9ac5c1a4c62a01143a016d9ba6a0b495ff7af7468c11947a3e888
2022-04-11 21:00:38 +00:00
drh
c133bab72a
The query flattener must add TK_IF_NULL_ROW opcodes on substituted values
...
that land on the left operand of a RIGHT JOIN, just as it already does for
the right operand of a LEFT JOIN.
FossilOrigin-Name: 8e02cdf5b1128f5e5b82d93903063415ec312694e5ccdd19e99fa35433f1b68a
2022-04-11 20:15:52 +00:00