Manuscript Offprint

arXiv:2608.25573

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

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

Yankai Rong

Renmin University of China

Beijing, China

yankairong@ruc.edu.cn

Qiang Yin

China Electronics Technology

Kingbase (Beijing) Technologies Inc.

Beijing, China

qyin@kingbase.com.cn

Shuang Liu ∗^{*}

Renmin University of China

Beijing, China

Shuang.Liu@ruc.edu.cn

Wei Lu

Renmin University of China

Beijing, China

lu-wei@ruc.edu.cn

Jinhao Dong

Renmin University of China

Beijing, China

jhdong@stu.pku.edu.cn

Xiaoyong Du

Renmin University of China

Beijing, China

duyong@ruc.edu.cn

Jianhua Wang

China Electronics Technology

Kingbase (Beijing) Technologies Inc.

Beijing, China

jhwang@kingbase.com.cn

Abstract

Relational Database Management Systems (RDBMSs) form the backbone of modern data-intensive applications, making their reliability and robustness of paramount importance. However, due to the large code base and immense code complexity, achieving high coverage in RDBMS testing remains a formidable challenge. Traditional fuzzing approaches rely on random SQL generation, which fails to capture the intricate correspondence between SQL and paths (SQL-to-path correspondence) within the codebase, leading to low code coverage. Symbolic execution-based methods can, in principle, address this issue but incur prohibitive computational costs and suffer from scalability bottlenecks on large systems.

We propose DBcover, an LLM-driven database test generation framework that performs white-box, code-aware SQL test generation through contextual reasoning. DBcover integrates lightweight dynamic analysis to extract SQL-to-path correspondence and call graphs as global context, and constructs source-level dependency information around target functions as local context. Both types of contextual information are organized within a unified knowledge graph, enabling efficient retrieval, reasoning, and reuse across iterative test generation. Built upon this contextual foundation, DBcover adopts a two-phase test generation strategy. In the seed selection phase, it identifies a semantically relevant existing test case by analyzing SQL-to-path relationships within the knowledge graph. In the query generation phase, the LLM, equipped with both global and local context, employs a fine-grained reasoning pipeline to synthesize new SQL test cases that accurately trigger previously uncovered code regions. Experimental results show that DBcover substantially outperforms existing fuzzers, achieving 80.1% and 82.3% coverage on PostgreSQL and MySQL. Experiments conducted on an enterprise RDBMS KingbaseES demonstrate the effectiveness and practical applicability of our approach on closed-source RDBMSs.

Keywords

DBMS, Large Language Model, Testcase Generation