Commit Graph

25 Commits

Author SHA1 Message Date
drh
b816ca9994 Correctly handle SELECT DISTINCT ... ORDER BY when all of the result set terms
are constant and there are more result set terms than ORDER BY terms.
Fix for these tickets: [c36cdb4afd504dc1], [4051a7f931d9ba24],
[d6fd512f50513ab7].

FossilOrigin-Name: 12ad822d9b827777526ca5ed5bf3e678d600294fc9b5c25482dfff2a021328a4
2023-03-16 20:54:29 +00:00
dan
247d09462e Add extra test cases.
FossilOrigin-Name: 0a922d141749cf3ef672f56449001e03f1a7e31822b66dcaf8550bb6e1b88cd3
2022-03-16 19:28:18 +00:00
drh
4ad9673d00 Do not allow the use of rowid for views and subqueries unless compiled
with -DSQLITE_ALLOW_ROWID_IN_VIEW.

FossilOrigin-Name: a2ddb89b206c13876d34c5f9e3db41cda72d6eb3fea31ffa8cc6daa1e1580e16
2021-04-07 18:17:53 +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
204b634222 Do not apply the optimization that omits DISTINCT if all result terms are
part of a UNIQUE index if the index is also a partial index.
Fix for the bug reported by
[forum:/forumpost/66954e9ece|forum post 66954e9ece].

FossilOrigin-Name: c2f940b02883e165172a4ca21c7095ffbef84ddc5367853dfeca93fda20d6056
2021-04-06 23:29:41 +00:00
drh
9be1339faf Comment improvements to on the distinct-agg optimization. Show a line in
the EQP output when using an ephemeral table to implement DISTINCT on an
aggregate.

FossilOrigin-Name: 037ca79e6032ca962b4f6182187bc12a7d91170d73630c8cd6fb191d2c183ee4
2021-03-24 19:44:01 +00:00
drh
cb49f5468e Further simplification and modularization of the EXPLAIN logic.
FossilOrigin-Name: aee1c12f4227cea9e8c6295cee3ec11797422c31b48c9468f176eb52f8261fe8
2020-03-23 19:14:11 +00:00
dan
9e10f9ab05 Ensure the SF_Aggregate flag on a SELECT statement is set if a DISTINCT is transformed to a GROUP BY. Ticket [9c944882].
FossilOrigin-Name: 1409758f72c0206cc48f9f7e789382472949523b7056ea46f8dcb93fd3ea60c6
2020-01-06 17:06:12 +00:00
drh
4e8b9925bf Fix a test case inside distinct.test.
FossilOrigin-Name: 61cb8a391a0c709340ac60ffd0c58f950567892a8404c2bec7b9b1f64b3cc5cf
2018-04-18 18:19:25 +00:00
drh
5015c9b50e New test cases for upsert.
FossilOrigin-Name: 907b5a37c539ea67c285c87399b494c7fe15014389a2ea3d49e90640b58946ae
2018-04-17 16:16:40 +00:00
drh
2edc5fd73a Remove an incorrect ALWAYS() macro. Fix for ticket [e5c6268dd807fa8950] -
a problem introduced in SQLite 3.9.0 and found by libFuzzer.

FossilOrigin-Name: 824ad96f72cb0c948ec98aca9d17a7e6790c575f
2015-11-24 02:10:52 +00:00
drh
dea7d70d1b Make sure that a DISTINCT query with an ORDER BY works correctly even if
it uses a descending index.  Fix for ticket [c5ea805691bfc4204b1cb9e].

FossilOrigin-Name: 0d3aef97ebddf422b8bdcbc5878970c6129e3f54
2014-12-04 21:54:58 +00:00
drh
6284db908a Fix query planner weights associated with choosing block-sorting. Fix
block sorting of tables with collating functions.  Fix various test cases.
All "veryquick" tests are now passing, though more tests need to be added.

FossilOrigin-Name: 01afbf97c0ff29667806e9a7c4d74ca717819de5
2014-03-19 23:24:49 +00:00
drh
826af37865 Change the OP_Found opcode so that it expands zero-blobs prior to comparing
them.  Fix for ticket [fccbde530a6583b]

FossilOrigin-Name: e2303d1b0c17b6e7494fb7db8264f4c2ac193723
2014-02-08 19:12:21 +00:00
drh
4fe425ad79 "make test" now passing.
FossilOrigin-Name: addd7f466d6ff55f82d907286650c26b06e9397b
2013-06-12 17:08:06 +00:00
drh
580c8c1816 Veryquick passes all tests now.
FossilOrigin-Name: 7b96115e81deab0aa0472839cf787ba3f2fc64a7
2012-12-08 03:34:04 +00:00
drh
053a128f55 Tighter VDBE code for the WHERE_DISTINCT_ORDERED case of DISTINCT keyword
handling.

FossilOrigin-Name: 94b48064db3cbb43e911fdf7183218b08146ec10
2012-09-19 21:15:46 +00:00
drh
3f4d1d1b02 Attempt to use a covering index even on a full table scan, under the theory
that the index will be smaller and require less disk I/O and thus be faster.

FossilOrigin-Name: cfaa7bc12847a7006ccc93815f2395ad5259744a
2012-09-15 18:45:54 +00:00
dan
6a36f43586 Do not consider a DISTINCT clause redundant unless a subset of the result-set is collectively subject to a UNIQUE constraint and it can be guaranteed that all columns of the subset are NOT NULL (either due to NOT NULL constraints WHERE clause terms). Fix for [385a5b56b9].
FossilOrigin-Name: 7b8548b1872cc1225355ba8311e93dd08d6526e2
2012-04-20 16:59:24 +00:00
dan
2f56da3f26 Changes to various test scripts so that veryquick.test runs with OMIT_COMPOUND_SELECT defined.
FossilOrigin-Name: 76bb649ee2633226324130f5898622c348f93769
2012-02-13 10:00:35 +00:00
drh
33f111dc72 Remove the undocumented PRAGMA omit_readlock hack.
FossilOrigin-Name: 96900c47e4fc6ed55cefc10d55d3d8d16bcb1d31
2012-01-17 15:29:14 +00:00
drh
1c9d835d49 Use OP_SorterOpen instead of OP_OpenEphemeral to implement GROUP BY.
FossilOrigin-Name: ebf819aaa555bd79fddfc0a6f9827a2539095d6c
2011-09-01 16:01:27 +00:00
dan
94e08d92f9 Fix a broken assert() in where.c.
FossilOrigin-Name: 090b29177fbc9faa83b560d92ddc3710d291776e
2011-07-02 06:44:05 +00:00
dan
6f3439697e Improve use of indexes to optimize DISTINCT queries.
FossilOrigin-Name: 6c202ea0247ff509f696eee3839975a88ed26cf2
2011-07-01 18:26:40 +00:00
dan
50118cdfdb Improvements and tests for detection of redundant DISTINCT qualifiers.
FossilOrigin-Name: 7337293c87fb563604dd6ad284f2d1e30c938b4c
2011-07-01 14:21:38 +00:00