diff --git a/simulator/generation/plan.rs b/simulator/generation/plan.rs index 3e6e1ab9e..12935d3d3 100644 --- a/simulator/generation/plan.rs +++ b/simulator/generation/plan.rs @@ -195,6 +195,7 @@ impl InteractionPlan { Query::Begin(_) => stats.begin_count += 1, Query::Commit(_) => stats.commit_count += 1, Query::Rollback(_) => stats.rollback_count += 1, + Query::Placeholder => {} } } for interactions in &self.plan { @@ -766,6 +767,11 @@ impl InteractionType { pub(crate) fn execute_query(&self, conn: &mut Arc) -> ResultSet { if let Self::Query(query) = self { + assert!( + !matches!(query, Query::Placeholder), + "simulation cannot have a placeholder Query for execution" + ); + let query_str = query.to_string(); let rows = conn.query(&query_str); if rows.is_err() { diff --git a/simulator/generation/query.rs b/simulator/generation/query.rs index 068e4f5e7..3408dca3b 100644 --- a/simulator/generation/query.rs +++ b/simulator/generation/query.rs @@ -111,6 +111,9 @@ impl QueryDiscriminants { | QueryDiscriminants::Rollback => { unreachable!("transactional queries should not be generated") } + QueryDiscriminants::Placeholder => { + unreachable!("Query Placeholders should not be generated") + } } } @@ -128,6 +131,9 @@ impl QueryDiscriminants { | QueryDiscriminants::Rollback => { unreachable!("transactional queries should not be generated") } + QueryDiscriminants::Placeholder => { + unreachable!("Query Placeholders should not be generated") + } } } } diff --git a/simulator/model/mod.rs b/simulator/model/mod.rs index 4af61b353..9e3d29db2 100644 --- a/simulator/model/mod.rs +++ b/simulator/model/mod.rs @@ -32,6 +32,8 @@ pub enum Query { Begin(Begin), Commit(Commit), Rollback(Rollback), + /// Placeholder query that still needs to be generated + Placeholder, } impl Query { @@ -70,6 +72,7 @@ impl Query { IndexSet::from_iter([table_name.clone()]) } Query::Begin(_) | Query::Commit(_) | Query::Rollback(_) => IndexSet::new(), + Query::Placeholder => IndexSet::new(), } } pub fn uses(&self) -> Vec { @@ -83,6 +86,7 @@ impl Query { | Query::Drop(Drop { table, .. }) => vec![table.clone()], Query::CreateIndex(CreateIndex { table_name, .. }) => vec![table_name.clone()], Query::Begin(..) | Query::Commit(..) | Query::Rollback(..) => vec![], + Query::Placeholder => vec![], } } @@ -116,6 +120,7 @@ impl Display for Query { Self::Begin(begin) => write!(f, "{begin}"), Self::Commit(commit) => write!(f, "{commit}"), Self::Rollback(rollback) => write!(f, "{rollback}"), + Self::Placeholder => Ok(()), } } } @@ -124,7 +129,6 @@ impl Shadow for Query { type Result = anyhow::Result>>; fn shadow(&self, env: &mut ShadowTablesMut) -> Self::Result { - tracing::info!("SHADOW {:?}", self); match self { Query::Create(create) => create.shadow(env), Query::Insert(insert) => insert.shadow(env), @@ -136,6 +140,7 @@ impl Shadow for Query { Query::Begin(begin) => Ok(begin.shadow(env)), Query::Commit(commit) => Ok(commit.shadow(env)), Query::Rollback(rollback) => Ok(rollback.shadow(env)), + Query::Placeholder => Ok(vec![]), } } } @@ -182,6 +187,9 @@ impl From for QueryCapabilities { | QueryDiscriminants::Rollback => { unreachable!("QueryCapabilities do not apply to transaction queries") } + QueryDiscriminants::Placeholder => { + unreachable!("QueryCapabilities do not apply to query Placeholder") + } } } } diff --git a/simulator/runner/execution.rs b/simulator/runner/execution.rs index e877a972f..e3cfef375 100644 --- a/simulator/runner/execution.rs +++ b/simulator/runner/execution.rs @@ -368,6 +368,9 @@ fn execute_query_rusqlite( } Ok(result) } + Query::Placeholder => { + unreachable!("simulation cannot have a placeholder Query for execution") + } _ => { connection.execute(query.to_string().as_str(), ())?; Ok(vec![])