Skip to main content

injection_point

Macro injection_point 

Source
macro_rules! injection_point {
    ($name:literal $(, $payload:expr)* $(,)?) => { ... };
}
Expand description

Hook a perf-irrelevant test-only injection point into a code path.

name must be a string literal (matches PG’s INJECTION_POINT() convention; we use the literal as a stable identifier across all builds). The optional payload expressions are evaluated only when the feature is on; in release builds they are bound through let _ = (…); which is enough to keep them typechecking without emitting code for any expression with no side effects (LLVM constant-folds the () tuple away — verified by cargo asm).

// Hot site
crate::injection_point!("planner_first_row_fetch", &stmt.from);
// Test
eng.execute("SELECT spg_injection_attach('planner_first_row_fetch', 'wait')")?;
let h = std::thread::spawn(move || eng2.execute("SELECT * FROM big")?);
// … assert worker parked …
eng.execute("SELECT spg_injection_wakeup('planner_first_row_fetch')")?;