mirror of
https://github.com/aljazceru/turso.git
synced 2026-02-09 02:04:22 +01:00
disable distinct without index_experimental
distinct uses indexes, therefore we need to disable them
This commit is contained in:
@@ -50,6 +50,14 @@ pub fn resolve_aggregates(top_level_expr: &Expr, aggs: &mut Vec<Aggregate>) -> R
|
||||
{
|
||||
Ok(Func::Agg(f)) => {
|
||||
let distinctness = Distinctness::from_ast(distinctness.as_ref());
|
||||
#[cfg(not(feature = "index_experimental"))]
|
||||
{
|
||||
if distinctness.is_distinct() {
|
||||
crate::bail_parse_error!(
|
||||
"SELECT with DISTINCT is not allowed without indexes enabled"
|
||||
);
|
||||
}
|
||||
}
|
||||
let num_args = args.as_ref().map_or(0, |args| args.len());
|
||||
if distinctness.is_distinct() && num_args != 1 {
|
||||
crate::bail_parse_error!(
|
||||
|
||||
@@ -202,6 +202,14 @@ fn prepare_one_select_plan<'a>(
|
||||
distinctness,
|
||||
..
|
||||
} = *select_inner;
|
||||
#[cfg(not(feature = "index_experimental"))]
|
||||
{
|
||||
if distinctness.is_some() {
|
||||
crate::bail_parse_error!(
|
||||
"SELECT with DISTINCT is not allowed without indexes enabled"
|
||||
);
|
||||
}
|
||||
}
|
||||
let col_count = columns.len();
|
||||
if col_count == 0 {
|
||||
crate::bail_parse_error!("SELECT without columns is not allowed");
|
||||
@@ -336,6 +344,15 @@ fn prepare_one_select_plan<'a>(
|
||||
0
|
||||
};
|
||||
let distinctness = Distinctness::from_ast(distinctness.as_ref());
|
||||
|
||||
#[cfg(not(feature = "index_experimental"))]
|
||||
{
|
||||
if distinctness.is_distinct() {
|
||||
crate::bail_parse_error!(
|
||||
"SELECT with DISTINCT is not allowed without indexes enabled"
|
||||
);
|
||||
}
|
||||
}
|
||||
if distinctness.is_distinct() && args_count != 1 {
|
||||
crate::bail_parse_error!("DISTINCT aggregate functions must have exactly one argument");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user