mirror of
https://github.com/tursodatabase/limbo.git
synced 2025-08-04 01:58:16 +00:00
![]() we had an incorrect optimization in `eliminate_orderby_like_groupby()` where it could remove e.g. the first term of the ORDER BY if it matched the first GROUP BY term and the result set was naturally ordered by that term. this is invalid. see e.g.: ```sql main branch - BAD: removes the `ORDER BY id` term because the results are naturally ordered by id. However, this results in sorting the entire thing by last name only! limbo> select id, last_name, count(1) from users GROUP BY 1,2 order by id, last_name desc limit 3; ┌──────┬───────────┬───────────┐ │ id │ last_name │ count (1) │ ├──────┼───────────┼───────────┤ │ 6235 │ Zuniga │ 1 │ ├──────┼───────────┼───────────┤ │ 8043 │ Zuniga │ 1 │ ├──────┼───────────┼───────────┤ │ 944 │ Zimmerman │ 1 │ └──────┴───────────┴───────────┘ after fix - GOOD: limbo> select id, last_name, count(1) from users GROUP BY 1,2 order by id, last_name desc limit 3; ┌────┬───────────┬───────────┐ │ id │ last_name │ count (1) │ ├────┼───────────┼───────────┤ │ 1 │ Foster │ 1 │ ├────┼───────────┼───────────┤ │ 2 │ Salazar │ 1 │ ├────┼───────────┼───────────┤ │ 3 │ Perry │ 1 │ └────┴───────────┴───────────┘ I also refactored sorters to always use the ast `SortOrder` instead of boolean vectors, and use the `compare_immutable()` utility we use inside btrees too. Closes #1365 |
||
---|---|---|
.. | ||
cli_tests | ||
test_files | ||
wal | ||
agg-functions.test | ||
all.test | ||
boolean.test | ||
changes.test | ||
cmdlineshell.test | ||
coalesce.test | ||
compare.test | ||
concat.test | ||
default_value.test | ||
delete.test | ||
drop_table.test | ||
gen-database.py | ||
glob.test | ||
groupby.test | ||
insert.test | ||
join.test | ||
json.test | ||
like.test | ||
math.test | ||
offset.test | ||
orderby.test | ||
pragma.test | ||
pyproject.toml | ||
README.md | ||
scalar-functions-datetime.test | ||
scalar-functions-printf.test | ||
scalar-functions.test | ||
select.test | ||
subquery.test | ||
tester.tcl | ||
testing.db | ||
testing_norowidalias.db | ||
testing_small.db | ||
testing_small.db-wal | ||
testing_user_version_10.db | ||
time.test | ||
total-changes.test | ||
transactions.test | ||
update.test | ||
vector.test | ||
where.test |