一句话:提出 MIST,用特征引导的错误驱动合成与 MCTS 变异,为专有 SQL 方言生成语法有效且高覆盖的测试用例。
数据库管理系统(DBMS)的可靠性依赖高质量 SQL 测试用例,但传统 fuzzing 在适配专有 SQL 方言时需要大量人工改造。轻量级大语言模型(LLM)虽可在安全与隐私约束下部署,却难以生成符合专有方言语法的查询,且生成的查询语义雷同、执行路径浅,覆盖率迅速饱和。为此,作者提出 MIST:一个基于 LLM 与蒙特卡洛树搜索的 DBMS 测试用例生成框架,分两阶段。第一阶段为特征引导的错误驱动测试用例合成,构建层次化特征树并利用错误反馈引导 LLM 生成,以产出语法有效、语义多样的方言查询;第二阶段为基于 MCTS 的测试用例变异,在覆盖率反馈下联合优化种子查询选择与变异规则应用,从而探索更深执行路径。作者在三个常用 DBMS 与四个轻量 LLM 上评估,相比行覆盖率最高的基线方法,行覆盖率平均提升 43.3%、函数覆盖率提升 32.3%、分支覆盖率提升 46.4%,在 Optimizer 模块的行覆盖率达 69.3%。
Database Management Systems (DBMSs) are fundamental infrastructure for modern data-driven applications, where thorough testing with high-quality SQL test cases is essential for ensuring system reliability. Traditional approaches such as fuzzing can be effective for specific DBMSs, but adapting them to different proprietary dialects requires substantial manual effort. Large Language Models (LLMs) present promising opportunities for automated SQL test generation, but face critical challenges in industrial environments. First, lightweight models are widely used in organizations due to security and privacy constraints, but they struggle to generate syntactically valid queries for proprietary SQL dialects. Second, LLM-generated queries are often semantically similar and exercise only shallow execution paths, thereby quickly reaching a coverage plateau. To address these challenges, we propose MIST, an LLM-based test case generatIon framework for DBMS through Monte Carlo Tree search. MIST consists of two stages: Feature-Guided Error-Driven Test Case Synthetization, which constructs a hierarchical feature tree and uses error feedback to guide LLM generation, aiming to produce syntactically valid and semantically diverse queries for different DBMS dialects, and Monte Carlo Tree Search-Based Test Case Mutation, which jointly optimizes seed query selection and mutation rule application guided by coverage feedback, aiming to boosting code coverage by exploring deeper execution paths. Experiments on three widely-used DBMSs with four lightweight LLMs show that MIST achieves average improvements of 43.3% in line coverage, 32.3% in function coverage, and 46.4% in branch coverage compared to the baseline approach with the highest line coverage of 69.3% in the Optimizer module.
DOI 原文 · arXiv · PDF(开放获取) · DBLP
@inproceedings{abs-2603-21530,
title = {LLM-Based Test Case Generation in DBMS through Monte Carlo Tree Search},
author = {Yujia Chen and Yingli Zhou and Fangyuan Zhang and Cuiyun Gao},
booktitle = {ICSE},
year = {2026},
doi = {10.1145/3774748.3793625}
}