MCPcopy Create free account
hub / github.com/MaterializeInc/materialize / decode

Method decode

src/repr/src/optimize.rs:198–216  ·  view source on GitHub ↗
(v: &str)

Source from the content-addressed store, hash-verified

196 }
197
198 fn decode(v: &str) -> Self {
199 // Accept both the Rust spelling (`true`/`false`, what `encode` and
200 // `CREATE CLUSTER ... FEATURES` produce) and the canonical system-var /
201 // PostgreSQL spellings (`on`/`off`, ...). A cluster-coherent scoped
202 // override may arrive as the var's canonical `on`/`off`.
203 match v.trim().to_lowercase().as_str() {
204 "t" | "true" | "on" | "1" | "y" | "yes" => true,
205 "f" | "false" | "off" | "0" | "n" | "no" => false,
206 // The writer only stores values that passed `canonicalize`, so this
207 // arm is unreachable in practice. Log rather than panic anyway: a
208 // stored bad value reaching the plan path would otherwise crash the
209 // optimizer on every query for the affected cluster. Fall back to
210 // `false`.
211 other => {
212 mz_ore::soft_panic_or_log!("invalid boolean optimizer feature override: {other:?}");
213 false
214 }
215 }
216 }
217}
218
219#[cfg(test)]

Callers 3

bench_roundtripFunction · 0.45
bench_jsonFunction · 0.45
bench_stringFunction · 0.45

Calls 2

as_strMethod · 0.45
trimMethod · 0.45

Tested by

no test coverage detected