From 4c76191fec91602380718fd40757296ceebcda5a Mon Sep 17 00:00:00 2001 From: Jussi Saurio Date: Fri, 15 Aug 2025 10:48:42 +0300 Subject: [PATCH] fix/sim: fix incorrect implementation of compound select generation Problem: sim was generating compound selects like this: - pick a random `table` - create a random single SELECT - create `n` random compound SELECTs (UNION ALL etc) assign a WHERE clause that always has a condition based on `table` This can result in e.g. ``` SELECT a FROM foo WHERE bar.x = 'baz' ``` Solution: Don't base the WHERE clause on a table that might not be referenced in the query. Again, the only reason this wasn't caught before was because `FaultyQuery` and `FsyncNoWait` are the only paths where this is actually tested with an assertion, and those are both disabled --- simulator/generation/query.rs | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/simulator/generation/query.rs b/simulator/generation/query.rs index fa0932e46..c0b3ce7cc 100644 --- a/simulator/generation/query.rs +++ b/simulator/generation/query.rs @@ -177,8 +177,6 @@ impl ArbitraryFrom<&SimulatorEnv> for SelectFree { impl ArbitraryFrom<&SimulatorEnv> for Select { fn arbitrary_from(rng: &mut R, env: &SimulatorEnv) -> Self { - let table = pick(&env.tables, rng); - // Generate a number of selects based on the query size // If experimental indexes are enabled, we can have selects with compounds // Otherwise, we just have a single select with no compounds @@ -196,11 +194,7 @@ impl ArbitraryFrom<&SimulatorEnv> for Select { let first = SelectInner::arbitrary_from(rng, env); let rest: Vec = (0..num_compound_selects) - .map(|_| { - let mut select = first.clone(); - select.where_clause = Predicate::arbitrary_from(rng, table); - select - }) + .map(|_| SelectInner::arbitrary_from(rng, env)) .collect(); Self {