use reifydb_catalog::catalog::{Catalog, flow::FlowToCreate};
use reifydb_core::{
error::diagnostic::catalog::persistent_requires_buffer,
interface::catalog::{flow::FlowStatus, view::View},
};
use reifydb_rql::query::QueryPlan;
use reifydb_transaction::transaction::admin::AdminTransaction;
use reifydb_value::{fragment::Fragment, return_error};
use crate::{Result, flow::compiler::compile_flow};
pub(crate) fn require_buffer_for_non_persistent(
txn: &AdminTransaction,
persistent: bool,
fragment: Fragment,
shape: &str,
) -> Result<()> {
if !persistent && !txn.multi.has_buffer() {
return_error!(persistent_requires_buffer(fragment, shape));
}
Ok(())
}
pub mod authentication;
pub mod binding;
pub mod deferred;
pub mod dictionary;
pub mod event;
pub mod identity;
pub mod migration;
pub mod namespace;
pub mod policy;
pub mod primary_key;
pub mod procedure;
pub mod property;
pub mod remote_namespace;
pub mod ringbuffer;
pub mod role;
pub mod series;
pub mod sink;
pub mod source;
pub mod subscription;
pub mod sumtype;
pub mod table;
pub mod tag;
pub mod test;
pub mod transactional;
pub(crate) fn create_deferred_view_flow(
catalog: &Catalog,
txn: &mut AdminTransaction,
view: &View,
plan: QueryPlan,
) -> Result<()> {
let flow = catalog.create_flow(
txn,
FlowToCreate {
name: Fragment::internal(view.name()),
namespace: view.namespace(),
status: FlowStatus::Active,
},
)?;
let _flow = compile_flow(catalog, txn, plan, Some(view), flow.id)?;
Ok(())
}