mirror of
https://github.com/aljazceru/turso.git
synced 2026-01-09 11:14:20 +01:00
Don't evaluate left side of 'x IN (...)' if right side is empty
This commit is contained in:
@@ -477,9 +477,6 @@ fn translate_condition_expr(
|
||||
// which is what SQLite also does for small lists of values.
|
||||
// TODO: Let's refactor this later to use a more efficient implementation conditionally based on the number of values.
|
||||
|
||||
let lhs_reg = program.alloc_register();
|
||||
let _ = translate_expr(program, select, lhs, lhs_reg, cursor_hint)?;
|
||||
|
||||
if rhs.is_none() {
|
||||
// If rhs is None, IN expressions are always false and NOT IN expressions are always true.
|
||||
if *not {
|
||||
@@ -506,6 +503,10 @@ fn translate_condition_expr(
|
||||
return Ok(());
|
||||
}
|
||||
|
||||
// The left hand side only needs to be evaluated once we have a list of values to compare against.
|
||||
let lhs_reg = program.alloc_register();
|
||||
let _ = translate_expr(program, select, lhs, lhs_reg, cursor_hint)?;
|
||||
|
||||
let rhs = rhs.as_ref().unwrap();
|
||||
|
||||
// The difference between a local jump and an "upper level" jump is that for example in this case:
|
||||
|
||||
Reference in New Issue
Block a user