A reader named Codemonkey found a SQL query running in production whose WHERE clause embeds its own debugging switches: (some conditions) AND (1 = 0 OR (1 = 1 AND (other conditions))).
WHERE (some conditions)
AND (1 = 0 OR (1 = 1 AND (other conditions)))The mechanics are grimly elegant. Flip the first equality and the query returns everything regardless of the real conditions. Flip the second and it returns nothing at all. The second option's practical value is questionable.
The likely origin story is familiar: an analyst's ad hoc query got promoted into a stored procedure that now runs on a schedule. The flags have never been touched since release, and they are documented nowhere. Remy Porter notes that constructs like this usually signal a deeper observability problem in the codebase.
Comments
No comments yet — be the first.
Open the discussion
No account or password needed — just enter your e-mail and we’ll send you a one-time sign-in link. First time here? You’re set up automatically.
Your rating will be applied automatically after you sign in.
Check your inbox
We’ve sent a sign-in link to …. Open it on this device — this tab will sign you in automatically.
Nothing arrived? Check your spam folder — and mark the mail as "Not spam" so it lands in your inbox next time.