NeurIPS 2026Coming to NeurIPS?Explore papers, orals & directions

DBcover: A White-box SQL Test Generation Framework for Coverage Improvement

Yankai Rong, Shuang Liu, Jinhao Dong, Qiang Yin, Wei Lu, Jianhua Wang, Xiaoyong DuarXiv 2026

TL;DR

DBcover is an LLM-driven, white-box test generation framework designed to maximize code coverage in complex Relational Database Management Systems (RDBMSs). By combining lightweight program analysis with structured LLM reasoning, it maps SQL inputs directly to internal execution paths via a knowledge graph, allowing it to synthesize highly precise queries that trigger deep, stateful database logic.

What Problem Does This Paper Address?

Ensuring the reliability of an RDBMS (like PostgreSQL or MySQL) is notoriously difficult. They feature massive, tightly coupled codebases managing everything from query optimization to storage engines. To test them, developers typically rely on automated SQL fuzzers.

However, traditional gray-box fuzzers suffer from a major blind spot: they lack SQL-to-path correspondence. They can tell if a query increased code coverage, but they don't understand why or how the SQL structure maps to specific internal code paths. On the other end of the spectrum, white-box methods like symbolic execution can map these paths in theory, but they suffer from severe path explosion and fail to scale to enterprise-grade systems.

While Large Language Models (LLMs) excel at code comprehension, simply feeding them millions of lines of database code is impossible due to context window limits. Without precise structural guidance, LLMs struggle to generate queries that hit deep, guarded code paths, often resulting in shallow testing or model hallucinations.

Methods

DBcover bridges this gap using a two-layer context collection strategy and a two-phase test generation workflow, all managed through a unified Code Context Knowledge Graph.

Figure 2: Overview of the DBcover framework.
  1. Knowledge Graph Construction: DBcover extracts global context (statically built call graphs and dynamic execution traces from existing tests) and local context (the target function's source code annotated with line-level coverage from gcov). It links SQL queries, execution paths, and functions together in a graph database (Neo4j).
  2. Phase 1: Seed Selection: When targeting an uncovered code region, DBcover calculates the shortest path distance in the call graph between the target function and already-executed paths. It selects the closest existing test case from the seed pool to serve as a semantic foundation.
  3. Phase 2: Query Generation via a 5-Stage Pipeline: Instead of asking the LLM to generate SQL in one shot, DBcover guides a locally deployed 32B parameter model (Qwen) through five fine-grained subtasks:
  4. Analyze Global Context: Understand the high-level DBMS operations of the seed.
  5. Retrieve Local Context: Examine the target function's body, signature, and uncovered lines.
  6. Analyze Trigger Conditions: Deduce the exact runtime conditions (e.g., specific table states or value thresholds) needed to reach the uncovered code.
  7. Generate Strategy: Propose minimal, targeted modifications to the seed query.
  8. Generate Test Case: Synthesize a self-contained, executable SQL script.

A closed-loop feedback mechanism executes the new query, updates the knowledge graph with new coverage data, and feeds any execution errors back into the LLM for iterative refinement.

Datasets

The framework was evaluated using the official regression test suites of two major open-source database systems:

  • PostgreSQL (v17.0)
  • MySQL (v8.0.33)

Additionally, to prove its viability on closed-source, proprietary software, it was tested on an industrial enterprise RDBMS:

  • KingbaseES

Key Insights and Ideas

  • The Power of Proximity: Functions that are close to each other in a static call graph usually share execution context (such as data structures or transaction states). Mutating a seed query that already gets "close" to the target is vastly more efficient than generating queries from scratch.
  • Unlocking Stateful Logic: Deep architectural paths are often guarded by complex runtime conditions, like cache thresholds. For example, a specific optimization might only trigger if the same partition is accessed 16 times consecutively. DBcover enables the LLM to deduce these exact numeric requirements and generate the repetitive INSERT statements needed to force the database state into that specific corner case.
  • Context Trumps Model Size: Rather than relying on massive, computationally expensive 70B+ parameter models, DBcover demonstrates that a highly structured, graph-augmented prompt pipeline allows a modest 32B parameter model to outperform generic LLM testing approaches.

Key Results

In 24-hour time-bounded experiments, DBcover significantly outperformed state-of-the-art database fuzzers:

  • PostgreSQL: Achieved 80.1% line coverage, a substantial leap over the initial regression test baseline (68.6%) and the leading IR-mutation fuzzer, SQUIRREL (69.0%).
  • MySQL: Reached 82.3% line coverage, outperforming the baseline (71.2%) and SQUIRREL (71.4%).
  • Standalone LLM Comparison: ShQveL, a standalone LLM-augmented generator without seed corpus or path-awareness, achieved only 31.5% on PostgreSQL and 25.7% on MySQL.
  • Industrial Application: On the closed-source KingbaseES, DBcover pushed coverage from 50.0% to 80.0% in the data type processing module, and from 68.0% to 81.4% in the metadata management module.

An ablation study removing the global context layer (DBcover_nse) resulted in a 4.4% to 5.1% drop in coverage, validating the necessity of the framework's knowledge graph and seed selection steps.

Limitations and Future Work

The authors noted that coverage naturally plateaus around the 80% mark due to inherent architectural boundaries. Much of the remaining uncovered code resides in components that are fundamentally unreachable via standard user-facing SQL queries—such as low-level operating system signal handlers, I/O error routines, and specific crash-recovery mechanisms. Furthermore, path conditions relying on macro-defined constants or deep internal function comparisons still occasionally bottleneck the reasoning capabilities of smaller LLMs.

Future work will focus on pairing DBcover's path-aware SQL generation with advanced bug-detection oracles, such as differential testing and metamorphic relations, to move from coverage improvement to systematic bug discovery.

Summary updated

BibTeX
@misc{rong2026dbcover,
  author = {Yankai Rong and Shuang Liu and Jinhao Dong and Qiang Yin and Wei Lu and Jianhua Wang and Xiaoyong Du},
  title = {{DBcover: A White-box SQL Test Generation Framework for Coverage Improvement}},
  year = {2026},
  eprint = {2608.25573},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2608.25573},
}
Figure