Commit Graph

26 Commits

Author SHA1 Message Date
drh
ce68b6bfeb Defer deleting subqueries in the compound-SELECT code generator until the
end of code generation, in order to avoid deleting expressions out from under
the aggregation function sanity checking assert()s that occur near the
end of SELECT code generation.  This fixes the assertion fault described by
[forum:/forumpost/cfcb4b461d|forum post cfcb4b461d].

FossilOrigin-Name: 600f1991e5c0a5d89cd8776a157b6fd72c7489791085876925e8dd7ab146fe1f
2021-08-21 16:42:58 +00:00
drh
6e5020e8da Also prohibit the use of rowid from a subquery. Add the
SQLITE_ALLOW_ROWID_IN_VIEW compile-time option to restore legacy behavior
in case somebody actually needs it.

FossilOrigin-Name: 14b1d56ef84b0e62b7f9c4e5f7f985ca10e770c8db59f54004ad892c2a2dcbfb
2021-04-07 15:45:01 +00:00
drh
426f4ab009 Make sure affinity is applied correctly on lower-bound range constraints
in the min() optimization.  Fix for ticket [a0bac8b3c3d1bb].

FossilOrigin-Name: b819bace9c2a0b0159122b26db96a8f50a6f0eac
2016-07-26 04:31:14 +00:00
dan
4ac391fc05 Attempt to further generalize the min/max optimization so that, if an appropriate index exists, it can be used by any aggregate query that contains only a single aggregate of the form max(colname) or min(colname) and does not contain a GROUP BY clause.
FossilOrigin-Name: 7280e14cd8f55896451847b432171e8750a07c81
2012-12-13 16:37:10 +00:00
drh
21172c4cc0 Add an optimization that attempts to run a subquery as a coroutine rather
than manifesting it into a temporary table.

FossilOrigin-Name: 7af3acbbd49a2114fcdada9ec907c68ba9b053bd
2012-10-30 00:29:07 +00:00
drh
0880a74633 Improved testing of the min/max optimization. (CVS 5373)
FossilOrigin-Name: fa07c360b708324c47c8e9931f1e2b1b24e4faf8
2008-07-08 18:05:26 +00:00
danielk1977
a9d1ccb9b0 First pass at optimizing max()/min() as described in #2853. Some refinements to come. (CVS 4687)
FossilOrigin-Name: c449e04f1870b1ff726c95c0bf1c6c6a22ca588a
2008-01-05 17:39:29 +00:00
drh
923782530b SQLite now always chooses the column names for compound selects using
the left-most select.  This makes SQLite work like other SQL database,
but it also is a change from historical behavior and may break some
scripts.  Ticket #1721. (CVS 3153)

FossilOrigin-Name: 80cda9f7ce83f2de6cd2fdaf6150bbc35b670fee
2006-03-26 01:21:22 +00:00
drh
3f219f46fc A SUM() of all NULLs returns NULL. A SUM() of nothing return 0.
A SUM() of a mixture of NULLs and numbers returns the sum of the
numbers.  Ticket #1413. (CVS 2677)

FossilOrigin-Name: 2e6230edfd651b40481ebad8aa01a22ac92ce80c
2005-09-08 19:45:57 +00:00
drh
3d1d95e625 The SUM() aggregate function returns an integer result if all inputs are
integers.  Any single non-integer input causes the result to be a floating
point value. (CVS 2669)

FossilOrigin-Name: 21adf4bd99e732650a1e8e9a1cc954126983a654
2005-09-08 10:37:01 +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
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
drh
92febd92ad Tcl interface transfers values directly between SQLite and Tcl_Objs, without
at translation to strings. (CVS 1898)

FossilOrigin-Name: e97c331362545ce21117776c7b61d3488668f2bf
2004-08-20 18:34:20 +00:00
drh
1af3fdb4dc An improved fix for the min() problem of ticket #800. (CVS 1804)
FossilOrigin-Name: b6e8b7a13cd9f90e2f7d963d9ddbe591571f3a27
2004-07-18 21:33:01 +00:00
drh
9eb516c0eb min() ignores NULL values. Ticket #800. (CVS 1802)
FossilOrigin-Name: 166234a2b61e1d6a501e48dde1caec0a02bec90b
2004-07-18 20:52:32 +00:00
danielk1977
3aeab9e438 Apply (1679) to version 3. Ticket #777. (CVS 1680)
FossilOrigin-Name: 0a26b9158095f0995fce2f0ccdfb383ab26c76a5
2004-06-24 00:20:04 +00:00
drh
6e17529e97 Fix the min/max optimizer so that it works when the FROM clause is a
subquery.  Ticket #658. (CVS 1293)

FossilOrigin-Name: 31c94acc72d318b5dec0fef1485621943add45c8
2004-03-13 14:00:36 +00:00
drh
268380ca9e Min() and max() functions honor the distinction between TEXT and NUMERIC
data.  Ticket #623.  typeof() is now a user function.  Some tests are
now failing due to ticket #521. (CVS 1272)

FossilOrigin-Name: adbe31adf1ad0ca723203ca3d7dc480324c60d43
2004-02-25 13:47:31 +00:00
drh
0c37e6309b Make sure min() and max() optimizations work for subqueries. Ticket #587. (CVS 1201)
FossilOrigin-Name: af73fbca839f8cbe39c21f1f9e439fe9b79005c8
2004-01-30 02:01:03 +00:00
drh
e5f50722b4 Make sure the min() and max() optimizer works correctly when there
is a LIMIT clause.  Ticket #396. (CVS 1057)

FossilOrigin-Name: c35e50717678703763c696e3e9b265add2ca6454
2003-07-19 00:44:14 +00:00
drh
d4d595f94c Make sure the min() and max() optimizations work on empty indexed tables.
Ticket #296. (CVS 914)

FossilOrigin-Name: 98ef6110068e5ed3cd77a14b004f890b79b731f7
2003-04-17 12:44:23 +00:00
drh
f570f011eb Refinements to NULL processing: NULLs are indistinct for DISTINCT and UNION.
Multiplying a NULL by zero yields zero. In a CASE expression, a NULL comparison
is considered false, not NULL.  With these changes, NULLs in SQLite now work
the same as in PostgreSQL and in Oracle. (CVS 600)

FossilOrigin-Name: da61aa1d238539dff9c43fd9f464d311e28d669f
2002-05-31 15:51:25 +00:00
drh
739105c72c Built-in aggregate functions (MIN, SUM, AVG, etc) should ignore NULL entires. (CVS 597)
FossilOrigin-Name: 19ae12bef210ae5fe171f10833faa38d640c129f
2002-05-29 23:22:23 +00:00
drh
bb113518f9 Bug fixes and additional test cases for the distinct-NULL patch. (CVS 592)
FossilOrigin-Name: 0e268d0c0faa02c3f95e1567cf631b7a04bfbdf0
2002-05-27 01:04:51 +00:00
drh
5cf8e8c7fa New ROWIDs are numbered sequentially. (CVS 383)
FossilOrigin-Name: 1686196a8aea326f616bc8205df99cd84d955ec4
2002-02-19 22:42:05 +00:00