mirror of
https://github.com/aljazceru/turso.git
synced 2026-01-22 09:24:26 +01:00
Disallow joining more than 63 tables
Returns an error instead of panicing
This commit is contained in:
@@ -187,6 +187,12 @@ fn optimize_table_access(
|
||||
order_by: &mut Vec<(Box<ast::Expr>, SortOrder)>,
|
||||
group_by: &mut Option<GroupBy>,
|
||||
) -> Result<Option<Vec<JoinOrderMember>>> {
|
||||
if table_references.joined_tables().len() > TableReferences::MAX_JOINED_TABLES {
|
||||
crate::bail_parse_error!(
|
||||
"Only up to {} tables can be joined",
|
||||
TableReferences::MAX_JOINED_TABLES
|
||||
);
|
||||
}
|
||||
let access_methods_arena = RefCell::new(Vec::new());
|
||||
let maybe_order_target = compute_order_target(order_by, group_by.as_mut());
|
||||
let constraints_per_table =
|
||||
|
||||
@@ -583,6 +583,11 @@ pub struct TableReferences {
|
||||
}
|
||||
|
||||
impl TableReferences {
|
||||
/// The maximum number of tables that can be joined together in a query.
|
||||
/// This limit is arbitrary, although we currently use a u128 to represent the [crate::translate::planner::TableMask],
|
||||
/// which can represent up to 128 tables.
|
||||
/// Even at 63 tables we currently cannot handle the optimization performantly, hence the arbitrary cap.
|
||||
pub const MAX_JOINED_TABLES: usize = 63;
|
||||
pub fn new(
|
||||
joined_tables: Vec<JoinedTable>,
|
||||
outer_query_refs: Vec<OuterQueryReference>,
|
||||
|
||||
Reference in New Issue
Block a user