SQL Differential Testing Oracles
This crate provides oracle implementations for differential SQL testing, inspired by the Crucible framework and SQLancer research.
Architecture
The OracleRunner trait defines a common interface for executing SQL queries
against different database engines. Implementations include:
DuckDbOracle: Executes queries in DuckDB (ground truth oracle)KimberliteOracle: Executes queries in Kimberlite (system under test)
Usage
use ;
let duckdb = new?;
let kimberlite = new?;
let sql = "SELECT COUNT(*) FROM users WHERE age > 30";
let duckdb_result = duckdb.execute?;
let kimberlite_result = kimberlite.execute?;
// Compare results to find bugs
assert_eq!;
# Ok::
Differential Testing Strategy
Differential testing compares two implementations of the same specification:
- Generate a valid SQL query
- Execute in both DuckDB (reference) and Kimberlite (SUT)
- Compare results byte-by-byte
- Report any discrepancies as bugs
Why DuckDB?
- Battle-tested SQL engine with 99.9% TPC-H compliance
- Embedded (no network overhead)
- Fast (columnar execution)
- Well-documented semantics
References
- Crucible: "Detecting Logic Bugs in DBMS" (154+ bugs found)
- SQLancer: Differential testing framework (148+ bugs in nghttp2)
- Jepsen: Distributed systems testing methodology