Finding bugs in database systems via query partitioning
Manuel Rigger, Zhendong Su
Abstract
Logic bugs in Database Management Systems (DBMS) are bugs that cause an incorrect result for a given query (e.g., by omitting a row that should be fetched). These bugs are critical, since they are likely to go unnoticed by users. We propose Query Partitioning, a general and effective approach for finding logic bugs in DBMS. The core idea of Query Partitioning is to, starting from a given original query, derive multiple, more complex queries (called partitioning queries), each of which computes a partition of the result. The individual partitions are then composed to compute a result set that must be equivalent to the original query's result set. A bug in the DBMS is detected when these result sets differ. Our intuition is that due to the increased complexity, the partitioning queries are more likely to stress the DBMS and trigger a logic bug than the original query. As a concrete instance of a partitioning strategy, we propose Ternary Logic Partitioning (TLP), which is based on the observation that a boolean predicate p can either evaluate to TRUE, FALSE, or NULL. Accordingly, a query can be decomposed to three partitioning queries, each of which computes its result on rows or intermediate results for which p, NOT p, and p IS NULL hold. This technique is versatile, and can be used to test WHERE, GROUP BY, as well as HAVING clauses, aggregate functions, and DISTINCT queries. As part of an extensive testing campaign, we found 175 bugs in widely-used DBMS such as MySQL, TiDB, SQLite, and CockroachDB, 125 of which have been fixed. Notably, 77 of these were logic bugs, while the remaining were error and crash bugs. We expect that the effectiveness and wide applicability of Query Partitioning will lead to its broad adoption in practice, and the formulation of additional partitioning strategies.
Ask Lune
Know this paper in minutes, not an afternoon.
Lune can read every page of it and the top-tier papers that cite it, and gives you its claims, its evidence and its limits, each one cited to the paper it comes from. No skimming, no AI slop.
71 top-tier papers have cited it since. Know what they found before your reviewers do.
Lune can draw on
the full paper · the top-tier papers that cite it · related work
Free to start. No credit card required.
Lineage
- Sequence-Oriented DBMS Fuzzing cites Detecting optimization bugs in database engines via non-optimizing reference engine construction
- Sequence-Oriented DBMS Fuzzing cites Testing Database Engines via Pivoted Query Synthesis
- Detecting optimization bugs in database engines via non-optimizing reference engine construction cites APOLLO: Automatic Detection and Diagnosis of Performance Regressions in Database Systems
- Detecting optimization bugs in database engines via non-optimizing reference engine construction cites Testing Database Engines via Pivoted Query Synthesis
- Testing Database Engines via Query Plan Guidance cites Detecting optimization bugs in database engines via non-optimizing reference engine construction
- Testing Database Engines via Query Plan Guidance cites APOLLO: Automatic Detection and Diagnosis of Performance Regressions in Database Systems
- Testing Database Engines via Query Plan Guidance cites Testing Database Engines via Pivoted Query Synthesis
- Detecting Logic Bugs of Join Optimizations in DBMS cites Detecting optimization bugs in database engines via non-optimizing reference engine construction
- Detecting Logic Bugs of Join Optimizations in DBMS cites APOLLO: Automatic Detection and Diagnosis of Performance Regressions in Database Systems
- Detecting Logic Bugs of Join Optimizations in DBMS cites Testing Database Engines via Pivoted Query Synthesis
- Finding bugs in Gremlin-based graph database systems via Randomized differential testing cites Detecting optimization bugs in database engines via non-optimizing reference engine construction
- Finding bugs in Gremlin-based graph database systems via Randomized differential testing cites APOLLO: Automatic Detection and Diagnosis of Performance Regressions in Database Systems
- Finding bugs in Gremlin-based graph database systems via Randomized differential testing cites Testing Database Engines via Pivoted Query Synthesis
- MT-Teql: Evaluating and Augmenting Neural NLIDB on Real-world Linguistic and Schema Variations cites Detecting optimization bugs in database engines via non-optimizing reference engine construction
- MT-Teql: Evaluating and Augmenting Neural NLIDB on Real-world Linguistic and Schema Variations cites Testing Database Engines via Pivoted Query Synthesis
Cited by top-tier papers71
- Testing Database Engines via Query Plan GuidanceJinsheng Ba, Manuel RiggerICSE 2023 · 39 citations
- MT-Teql: Evaluating and Augmenting Neural NLIDB on Real-world Linguistic and Schema VariationsPingchuan Ma, Shuai WangVLDB 2022 · 38 citations
- Finding bugs in Gremlin-based graph database systems via Randomized differential testingYingying Zheng, Wensheng Dou, Yicheng Wang, Zheng Qin et al.ISSTA 2022 · 36 citations
- Detecting Logic Bugs of Join Optimizations in DBMSXiu Tang, Sai Wu, Dongxiang Zhang, Feifei Li et al.SIGMOD 2023 · 34 citations
- Sequence-Oriented DBMS FuzzingJie Liang, Yaoguang Chen, Zhiyong Wu, Jingzhou Fu et al.ICDE 2023 · 29 citations
Builds on6
- Testing Database Engines via Pivoted Query SynthesisManuel Rigger, Zhendong SuOSDI 2020 · 150 citations
- Detecting optimization bugs in database engines via non-optimizing reference engine constructionManuel Rigger, Zhendong SuFSE 2020 · 104 citations
- Structure-invariant testing for machine translationPinjia He, Clara Meister, Zhendong SuICSE 2020 · 84 citations
- Validating SMT solvers via semantic fusionDominik Winterer, Chengyu Zhang, Zhendong SuPLDI 2020 · 80 citations
- APOLLO: Automatic Detection and Diagnosis of Performance Regressions in Database SystemsJinho Jung, Hong Hu, Joy Arulraj, Taesoo Kim et al.VLDB 2020 · 77 citations
Related papers
- Testing Database Systems via Differential Query ExecutionJiansen Song, Wensheng Dou, Ziyu Cui, Qianwang Dai et al.ICSE 2023 · 26 citations
- Constant Optimization Driven Database System TestingChi Zhang, Manuel RiggerSIGMOD 2025 · 8 citations
- Testing Graph Database Engines via Query PartitioningMatteo Kamm, Manuel Rigger, Chengyu Zhang, Zhendong SuISSTA 2023 · 29 citations
- Pinolo: Detecting Logical Bugs in Database Management Systems with Approximate Query SynthesisZongyin Hao, Quanfeng Huang, Chengpeng Wang, Jianfeng Wang et al.USENIX ATC 2023 · 26 citations
- SRS: Detecting Logic Bugs of Join Implementation in DBMSs via Set Relation SynthesisJinhui Lai, Chi Zhang, Bingyan Li, Chenglin Liang et al.SIGMOD 2026 · 4 citations
