Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions fuzz/fuzz_targets/sql_exec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
#![no_main]

use kite_sql::binder::{command_type, CommandType};
use kite_sql::db::{prepare_all, DataBaseBuilder, Database, Statement};
use kite_sql::db::{DataBaseBuilder, Database, Statement};
use kite_sql::storage::lmdb::LmdbStorage;
use kite_sql::types::value::DataValue;
use libfuzzer_sys::fuzz_target;
Expand Down Expand Up @@ -135,7 +135,7 @@ fn strip_slt(script: &str) -> String {
}

fn run_one(db: &mut Database<LmdbStorage>, sql: &str) {
let Ok(statements) = prepare_all(sql) else {
let Ok(statements) = db.prepare_all(sql) else {
return;
};
// `split(';')` leaves one statement per chunk except for `;` inside
Expand Down
2 changes: 2 additions & 0 deletions src/bin/shell.rs
Original file line number Diff line number Diff line change
Expand Up @@ -419,6 +419,7 @@ Transaction commands:
}
}

// GRCOV_EXCL_START
#[cfg(test)]
mod tests {
use super::*;
Expand Down Expand Up @@ -557,6 +558,7 @@ Transaction commands:
);
}
}
// GRCOV_EXCL_STOP
}

#[cfg(not(target_arch = "wasm32"))]
Expand Down
19 changes: 17 additions & 2 deletions src/binder/aggregate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -273,8 +273,21 @@ impl<T: Transaction, A: AsRef<[(usize, LogicalType)]>> Binder<'_, '_, T, A> {
return Ok(());
}

HavingOrderByValidator::new(&self.context.group_by_exprs, &self.context.agg_calls)
.visit(expr, arena)
Self::validate_having_orderby_with_outputs(
expr,
&self.context.agg_calls,
&self.context.group_by_exprs,
arena,
)
}

pub(crate) fn validate_having_orderby_with_outputs(
expr: ExprRef,
agg_calls: &[ExprRef],
group_by_exprs: &[ExprRef],
arena: &PlanArena<'_>,
) -> Result<(), DatabaseError> {
HavingOrderByValidator::new(group_by_exprs, agg_calls).visit(expr, arena)
}
}

Expand Down Expand Up @@ -405,6 +418,7 @@ impl ExprVisitorMut for AggregateOutputBinder<'_> {
}
}

// GRCOV_EXCL_START
#[cfg(all(test, not(target_arch = "wasm32")))]
mod tests {
use super::AggregateOutputBinder;
Expand Down Expand Up @@ -576,3 +590,4 @@ mod tests {
Ok(())
}
}
// GRCOV_EXCL_STOP
2 changes: 2 additions & 0 deletions src/binder/create_table.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ impl<T: Transaction, A: AsRef<[(usize, LogicalType)]>> Binder<'_, '_, T, A> {
}
}

// GRCOV_EXCL_START
#[cfg(all(test, not(target_arch = "wasm32")))]
mod tests {
use super::*;
Expand Down Expand Up @@ -125,3 +126,4 @@ mod tests {
Ok(())
}
}
// GRCOV_EXCL_STOP
2 changes: 2 additions & 0 deletions src/binder/distinct.rs
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ impl ExprVisitorMut for DistinctOutputBinder<'_> {
}
}

// GRCOV_EXCL_START
#[cfg(all(test, not(target_arch = "wasm32")))]
mod tests {
use super::DistinctOutputBinder;
Expand Down Expand Up @@ -213,3 +214,4 @@ mod tests {
Ok(())
}
}
// GRCOV_EXCL_STOP
12 changes: 10 additions & 2 deletions src/binder/expr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -302,9 +302,17 @@ impl<'a, T: Transaction, A: AsRef<[(usize, LogicalType)]>> Binder<'a, '_, T, A>
let (sub_query, column, correlated) =
self.bind_subquery_plan_with_output(Some(&left_ty), arena, build)?;

if !self.context.is_step(&QueryBindStep::Where) {
if !matches!(
self.context.step_now(),
QueryBindStep::Where | QueryBindStep::Project
) {
return Err(DatabaseError::UnsupportedStmt(
"quantified subqueries require WHERE or SELECT list".into(),
));
}
if correlated && self.context.is_step(&QueryBindStep::Project) {
return Err(DatabaseError::UnsupportedStmt(
"quantified subqueries can only appear in `WHERE`".to_string(),
"correlated quantified subqueries in SELECT are not supported yet".into(),
));
}

Expand Down
6 changes: 3 additions & 3 deletions src/binder/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,7 @@ mod update;
mod window;

#[cfg(feature = "parser")]
pub(crate) use parser::parse_statement;
#[cfg(feature = "parser")]
pub use parser::{command_type, prepare_all, CommandType, Statement};
pub use parser::{command_type, CommandType, Statement};
#[cfg(feature = "orm")]
pub use select::{BindPlanFrom, BindPlanSelectList};
#[cfg(feature = "orm")]
Expand Down Expand Up @@ -691,6 +689,7 @@ pub(crate) fn is_valid_identifier(s: &str) -> bool {
&& !s.chars().all(|c| c == '_')
}

// GRCOV_EXCL_START
#[cfg(all(test, not(target_arch = "wasm32")))]
pub mod test {
use crate::binder::{is_valid_identifier, Binder, BinderContext};
Expand Down Expand Up @@ -842,3 +841,4 @@ pub mod test {
assert!(!is_valid_identifier("____"));
}
}
// GRCOV_EXCL_STOP
Loading
Loading