Commit Graph

46 Commits

Author SHA1 Message Date
dan da03c1e65e Avoid assuming that an expression that contains the sub-expression (? IS FALSE) or (? IS TRUE) may only be true if ? is non-null. Fix for [a976c487].
FossilOrigin-Name: eb7ed90b8a65748f0721aaf7bdddd2207f552be5015603fbfb7044d815ae2f36
2019-10-09 21:14:00 +00:00
dan b6a9121bb3 Fix another case where SQLite assumes that if "~(? AND FALSE)" is true, "?" must be non-null.
FossilOrigin-Name: 616f5663b3dbd0929128c0990fc6d8bba1513c7ae196b87c450ac0b3b3203ecd
2019-08-29 15:50:16 +00:00
drh 9e9a67adb0 Ensure the functions that appear to be constant are not factored out of
expression that originate on the right-hand side of a LEFT JOIN.
Ticket [6710d2f7a13a2997]

FossilOrigin-Name: 500c9152daaf11cf69d778aa8592175f6088337c6667c59af6df3a24cd81eb0e
2019-08-17 17:07:15 +00:00
drh d57936721b The IS NOT NULL operator does not imply that the operand is never NULL.
Fix for ticket [5948e09b8c415bc45da5cf]

FossilOrigin-Name: d840e9bb023a1e84a7739d764a0f6cf608fc3183ff8c366fcdb486ebd932f0c1
2019-02-05 14:36:33 +00:00
drh 0ad7aa8182 Limit the size of SrcList objects to 200 entries (compile-time configurable
using -DSQLITE_MAX_SRCLIST=n).  The maximum number of tables in a join has
always been 64, so this is not a real constraint on capability.  Limiting the
size of a SrcList prevents DOS attacks (discovered by OSSFuzz) using crazy
nexted CTE joins.

FossilOrigin-Name: 7cac614d5df55eb092b863163483b6782b942b21bd15fd787576fef5619fa849
2019-01-17 14:34:46 +00:00
dan 0493222ff8 Fix a problem causing the LEFT JOIN strength reduction optimization to be
incorrectly applied in some cases where the WHERE clause of the query contains
a filter expression of the form "lhs.x IS NOT ?".

FossilOrigin-Name: 1fdaf2c34431adcac1c7ff29aae0623c4cbaa6a7f38e843c786bd407d8b3e730
2018-04-10 15:31:56 +00:00
dan a1054dcc3f Fix a problem causing the LEFT JOIN strength reduction optimization to be
incorrectly applied in some cases where the WHERE clause of the query contains
a filter expression of the form NOT(x AND y). Ticket [1e39b966].

FossilOrigin-Name: 38d319c153641ea4138fab2d5a47c31a86f57a071a1e1c299ca54c980cfb2b60
2018-04-10 12:10:01 +00:00
drh e3eff266bc Yet another fault in the sqlite3ExprImpliesNotNull() routine, causing errors
in the LEFT JOIN strength reduction optimization of check-in
[dd568c27b1d76563].

FossilOrigin-Name: e88cf3d4df64097ebc19aae464b88d0faf9b7d4c30d057042b582d78327e7ad3
2018-03-24 15:47:31 +00:00
drh 2c492061ce Bug fix in the LEFT JOIN strength reduction optimization of
check-in [dd568c27b1d76563].  The sqlite3ExprImpliesNotNull() routine was
mistakenly assuming that a CASE expression must always be NULL if contained
any reference to a variable that was NULL.

FossilOrigin-Name: cf171abe954a5f25262161dd69f2e8cecdbf9446c3f6b298201507dbc743567e
2018-03-24 13:24:02 +00:00
dan bd11a2acbb Ensure that the query planner knows that any column of a flattened LEFT JOIN
can be NULL even if that column is labeled with "NOT NULL".
Fix for ticket [892fc34f173e99d8].

FossilOrigin-Name: 483462682d3a57fb9dd85b4772596e9738f1694a454b8ebbc480b9452733e88d
2017-06-20 17:43:26 +00:00
drh f43ce0b445 The TK_IF_NULL_ROW expression node must be treated as a variable that
references the table Expr.iTable.
Proposed fix for ticket [7fde638e94287d2c].

FossilOrigin-Name: 77fc23013cebc7797985864b91d78db5d0e2469511732044ebfaf02b891c979a
2017-05-25 00:08:48 +00:00
drh 1d1fc5e385 Disable the LEFT JOIN flattening optimization for aggregate queries, as it
does not currently work.  Further fix for ticket [cad1ab4cb7b0fc344].

FossilOrigin-Name: 44b21e35c92137cc519d0cc87c627cc531d0bd442a7b9a7356fa2c6bc5f70fb6
2017-05-23 15:21:37 +00:00
drh eff0a7b25e Ensure that the expression rewriter inside the query flattener decends into
the substructure of the TK_IF_NULL_ROW operator.  This is a continuation
of the fix for ticket [cad1ab4cb7b0fc344].

FossilOrigin-Name: 941d8142b7c9a96ff143d1add3c86cf42d61fd08e532d400dac555f23eadbcfb
2017-05-23 12:36:13 +00:00
drh 3f1e9e00e6 When flattening a query, make sure iTable attribute of TK_IF_NULL_ROW
operators (that result from a prior flattening of a LEFT JOIN) are updated
correctly.  Fix for ticket [cad1ab4cb7b0fc344].

FossilOrigin-Name: 92c178507df553e4f1110342c8f9b11b3ee37989e1d634fcaccabf657befa22f
2017-05-23 01:21:07 +00:00
dan 35175bf7ab If a query contains "FROM t1 LEFT JOIN t2, t3, t4", ensure that tables t3 and t4 are not scanned before t2. The trunk already does this.
FossilOrigin-Name: 0d9edfab9fb61322620f188b48ae2a1798a07581
2015-06-08 18:48:29 +00:00
drh 71607c77c8 SQLite has long accepted some unadvertised and non-standard join syntax.
Add a test to ensure that future versions continue to accept this non-standard
syntax, to avoid breaking legacy applications that use the undefined syntax.

FossilOrigin-Name: 824dde7fc48dbca6d6c956c4eb79bbfa2d139ee5
2014-07-18 17:39:48 +00:00
dan a6eaa635cc Avoid running a couple of test cases that use realloc() extensively if SQLITE_MEMDEBUG is defined.
FossilOrigin-Name: e406d4bb786a34cdd5dd23ed39f35dfce3e1cabd
2014-03-05 19:13:32 +00:00
dan 13ef14afc1 Add tests to join.test to verify that it is not possible to use more than 64 tables in a join.
FossilOrigin-Name: ef1a998625e1fc051732228844388d6c59665382
2014-03-05 16:15:07 +00:00
dan f7b0b0ad5f When generating WHERE clause terms internally for NATURAL and USING joins, identify the table by its position in the FROM list, not by its name or alias. Fix for [b73fb0bd64].
FossilOrigin-Name: 6fe6371175482d38ac4aeea994c7b20c18b7de01
2009-10-19 15:52:32 +00:00
danielk1977 bd1a0a4f61 Report an error if a USING or ON clause is specified following a from-list element that is not to the right of a join operator. Fix for #3846. (CVS 6832)
FossilOrigin-Name: 29b48972b65a17dab343b063a620cf8d456a923c
2009-07-01 16:12:07 +00:00
drh da55c48a9a Expand table.* properly on a USING or a NATURAL join. Ticket #3522. (CVS 5979)
FossilOrigin-Name: 06d206ef7d5e433ccde347d63dfcd2177545e1fd
2008-12-05 00:00:07 +00:00
drh 2b300d5d6f Do not flatten the right term of a LEFT join. Ticket #3300. (CVS 5565)
FossilOrigin-Name: 8947c72f93d0b79c8061a3bfd5ab595edfb155a5
2008-08-14 00:19:48 +00:00
danielk1977 10235605ff Add a test case to join.test. No code changes, no bugs found. (CVS 5384)
FossilOrigin-Name: 417aa1580abec8cc335dcb6ac36245c081a31ef8
2008-07-09 14:47:21 +00:00
drh a9671a22b3 Remove obsolete code from select.c, including the "affinity" parameter
to the sqlite3Select() module. (CVS 5380)

FossilOrigin-Name: cbd3c1585b7a8f8042aa1448fe1be87de056c41a
2008-07-08 23:40:20 +00:00
danielk1977 4b2688ab31 Modifications so that compilation and testing with the various OMIT macros defined works. (CVS 3276)
FossilOrigin-Name: c6ea353bd9f5fe6c9cc3349d2034ada283f9c80e
2006-06-20 11:01:07 +00:00
drh 41714d6f83 Allow WHERE clause terms on the left table of a LEFT OUTER JOIN to
contain aggregate subqueries.  Ticket #1697. (CVS 3117)

FossilOrigin-Name: a286e54e26f9a364127649eeea160d5fa8928faf
2006-03-02 04:44:23 +00:00
drh 873fac0cae Avoid ambiguous column name errors when the column name is in the USING clause
of a join.  Ticket #743. (CVS 2495)

FossilOrigin-Name: 6a51bdeeff8312fa54fa2b1200f823428f35d605
2005-06-06 17:11:46 +00:00
drh 355ef36114 Naming the join columns in the result set of a natural join does not result
in an "ambiguous column name" error.  Ticket #1217. (CVS 2494)

FossilOrigin-Name: 265fb6079c0a4b7a93f063939436db494ff1d56c
2005-06-06 16:59:24 +00:00
drh 7bf5661068 Final preparations for the 3.1.0 alpha release. (CVS 2255)
FossilOrigin-Name: 17122c7e8e9cae36f1ffa7b42bd69d702980ac6a
2005-01-21 15:52:32 +00:00
danielk1977 e61b9f4f3c Modify test scripts to work when SQLITE_OMIT_SUBQUERY (but no other OMIT macros) is defined. (CVS 2252)
FossilOrigin-Name: d4e19efcef68d834c55c7d496cdb3696d63a31a2
2005-01-21 04:25:47 +00:00
danielk1977 3e8c37e7f8 Modify test scripts to work when SQLITE_OMIT_SUBQUERY (along with other OMIT macros) is defined. (CVS 2251)
FossilOrigin-Name: bb0254ab14417f0ab40f10f37cb63a60507f070a
2005-01-21 03:12:14 +00:00
drh 030530de9b Make sure USING and NATURAL work on joins even if the columns are renamed
using an AS phrase.  Ticket #523. (CVS 2233)

FossilOrigin-Name: c06add57bf0ce17503181b584ea4197b39b9e538
2005-01-18 17:40:04 +00:00
drh 47a6db2bfd Column names coming back from a SELECT are now just the name of the
source column without the "table." prefix. In other words,
"PRAGMA short_column_names=ON" is now the default.
This makes the names of columns behave more like other SQL engines.
The old behavior can be restored by setting "PRAGMA short_column_names=OFF". (CVS 2231)

FossilOrigin-Name: 9295050af1bf2d9d4dc63adc225a2848d67cbe17
2005-01-18 16:02:40 +00:00
danielk1977 27c774388a Ensure tests pass when SQLITE_OMIT_COMPOUND_SELECT is defined. (CVS 2138)
FossilOrigin-Name: 007be591b7829f9ff38e4b14ba5a5043796c2ff3
2004-11-22 13:35:41 +00:00
danielk1977 0fa8ddbdec Modify test suite to work when SQLITE_OMIT_VIEW is defined. (CVS 2132)
FossilOrigin-Name: 711e8d7695dfc74b3f1ee00591dcdda2cd7fc7d5
2004-11-22 08:43:32 +00:00
drh dab3518880 Remove support for the Oracle8 outer join syntax. (CVS 1106)
FossilOrigin-Name: 824430b3ce435386b83ceb882f1510ac9f27d8fa
2003-09-27 13:39:38 +00:00
drh 3fc673e622 Do not flatten a subquery which is the right term of a LEFT OUTER JOIN
if the subquery contains a WHERE clause.  Ticket #350. (CVS 1027)

FossilOrigin-Name: dd8943e8583cf7ed3b662570a5607856fd246dac
2003-06-16 00:40:34 +00:00
drh 8af4d3ace6 Restrain the flattener in the presence of outer joins. Ticket #306. (CVS 958)
FossilOrigin-Name: 6d4b6597e560578253960d9876dc8c8657f41fef
2003-05-06 20:35:16 +00:00
drh 50cceb36b6 When the right table in a LEFT OUTER JOIN contains an INTEGER PRIMARY KEY
make sure that key is NULL if there is no row in the right table that
matches the current row in the left table.  Tickets #246 and #247. (CVS 873)

FossilOrigin-Name: 6a45fe3bd7e19cf9c20fc6cb65b0269cdd704490
2003-02-20 01:48:12 +00:00
drh 1f16230b5c Minimal support for oracle8 outer join syntax. (CVS 771)
FossilOrigin-Name: 31df3690d0fe4bd4a293cbe8ca9a26c98c3ed3ce
2002-10-27 19:35:33 +00:00
drh c8f8b632c3 Fix a bug in the left outer join logic. (CVS 758)
FossilOrigin-Name: 6c0f44bd6374010f7a4a091e585eb36e0665f96f
2002-09-30 12:36:26 +00:00
drh f1351b6759 Fix for ticket #124: Fix a stack VDBE overflow problem on joins on an
INTEGER PRIMARY KEY. (CVS 700)

FossilOrigin-Name: fe329e078fa209faf62e08599a00c7efa75b8501
2002-07-31 19:50:26 +00:00
drh 5ad1a6c8c4 Fix for tickets #90 and #89: Make the AS keyword optional again. (CVS 654)
FossilOrigin-Name: 1f8a73b1c3833e3924196458d4c1ecca90f63662
2002-07-01 12:27:09 +00:00
drh 3b167c7583 Additional test cases added. The following bug fixed: A segfault was occurring
if a VIEW consisted of a join with a USING clause. (CVS 651)

FossilOrigin-Name: 96515b813eb57e1f48c28d357d1f38639b2fdcfa
2002-06-28 12:18:47 +00:00
drh 195e6967fb Additional testing of LEFT OUTER JOIN. (CVS 588)
FossilOrigin-Name: d8d04c14f18d1feba89ccea0be70530a18248c51
2002-05-25 00:18:20 +00:00
drh ad2d8307ac Initial implementation of LEFT OUTER JOIN including the expanded SQL92 join
syntax. The basic functionality is there but there is still a lot of testing
to do. (CVS 587)

FossilOrigin-Name: 99bd1f5b9a1a20bfeefe15c00d96a34a5f40923e
2002-05-24 20:31:36 +00:00