#[cfg(feature = "sql")]
use crate::{
db::{
Db,
executor::{
SharedPreparedExecutionPlan, StructuralProjectionRequest,
StructuralProjectionScanBudget, execute_structural_projection_rows,
},
},
error::InternalError,
traits::CanisterKind,
value::Value,
};
use icydb_diagnostic_code::DiagnosticExecutionLane;
#[cfg(feature = "sql")]
pub(in crate::db) fn execute_sql_projection_rows_for_canister<C>(
db: &Db<C>,
prepared_plan: SharedPreparedExecutionPlan,
) -> Result<(Vec<Vec<Value>>, u32), InternalError>
where
C: CanisterKind,
{
let rows = execute_structural_projection_rows(
db,
StructuralProjectionRequest::new(prepared_plan, DiagnosticExecutionLane::TrustedRead),
)?;
let row_count = rows.row_count();
let projected = rows.into_value_rows();
Ok((projected, row_count))
}
#[cfg(feature = "sql")]
pub(in crate::db) fn execute_sql_projection_rows_for_canister_with_scan_budget<C>(
db: &Db<C>,
prepared_plan: SharedPreparedExecutionPlan,
scan_budget: StructuralProjectionScanBudget,
) -> Result<(Vec<Vec<Value>>, u32), InternalError>
where
C: CanisterKind,
{
let rows = execute_structural_projection_rows(
db,
StructuralProjectionRequest::new(prepared_plan, DiagnosticExecutionLane::Mutation)
.with_scan_budget(scan_budget),
)?;
let row_count = rows.row_count();
let projected = rows.into_value_rows();
Ok((projected, row_count))
}