Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(executor): limit should exit early when offset and limit are both 0 #506

Merged
merged 1 commit into from
Feb 20, 2022
Merged

Conversation

xxchan
Copy link
Member

@xxchan xxchan commented Feb 19, 2022

Fix #264

The issue can be reproduced using memory engine like this: (Btw, the sqlogictest fails for both disk & memory engines)

> create table t(x int);insert into t values (0);insert into t values (0);
> select * from t limit 0;

The execution process is

processed 0, cardinality 1, offsef 0, limit 0
processed 1, cardinality 1, offsef 0, limit 0 # boom

Because when offset=limit=0, start=end=0, and thus it will continue.

let start = processed.max(self.offset) - processed;
let end = (processed + cardinality).min(self.offset + self.limit) - processed;
processed += cardinality;
if start >= end {
continue;
}

@xxchan xxchan requested a review from skyzh February 19, 2022 18:37
Copy link
Member

@skyzh skyzh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@skyzh skyzh merged commit 83a93c6 into risinglightdb:main Feb 20, 2022
@xxchan xxchan deleted the limit branch February 20, 2022 08:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

executor: LimitExecutor will panic if all chunks only have 1 element
2 participants