arXivDaily arXiv每日学术速递 周一至周五更新
感恩节,周五至周末无更新,大家顺遂。周一再来吧
arXiv 2604.06231cs.DBcs.AIcs.CLcs.IRcs.SE
收藏

利用大型语言模型自动合成数据库原生函数代码

Automating Database-Native Function Code Synthesis with LLMs

Shanghai Jiao Tong University(上海交通大学);Tsinghua University(清华大学);National University of Singapore(新加坡国立大学)

Wei Zhou, Xuanhe Zhou, Qikang He, Guoliang Li, Bingsheng He, Quanqing Xu, Fan Wu

AI总结:

本文提出DBCooker系统,通过多模块协同解决数据库原生函数合成难题,实现更高精度的自动代码生成,实验显示在SQLite、PostgreSQL和DuckDB上准确率提升34.55%。

摘要:

数据库系统在其内核中不断增加功能以支持新应用和业务迁移。这种增长导致对自动数据库原生函数合成的迫切需求。尽管最近的LLM基于代码生成(如Claude Code)显示出潜力,但它们过于通用,无法满足数据库特定开发的需求。数据库函数合成本质上复杂且易出错,单个函数合成可能涉及注册多个函数单元、链接内部引用和正确实现逻辑。为此,我们提出DBCooker,一个基于LLM的自动合成数据库原生函数的系统。它包含三个组件:首先,函数特征模块聚合多源声明,识别需要专门编码的函数单元,并追踪跨单元依赖。其次,我们设计了三种操作来解决主要合成挑战:(1)基于伪代码的编码计划生成器,通过识别关键元素如可重用引用函数来构建结构化实现骨架;(2)由概率先验和组件意识引导的混合填空模型,将核心逻辑与可重用的例行程序整合;(3)三级逐步验证,包括语法检查、标准符合性和LLM引导的语义验证。最后,一种自适应协调策略将这些操作与现有工具统一,并通过相似函数的协调历史动态排序。结果表明,DBCooker在SQLite、PostgreSQL和DuckDB上优于其他方法,平均准确率提高34.55%,并能合成最新版SQLite(v3.50)中不存在的新函数。

英文摘要:

Database systems incorporate an ever-growing number of functions in their kernels (a.k.a., database native functions) for scenarios like new application support and business migration. This growth causes an urgent demand for automatic database native function synthesis. While recent advances in LLM-based code generation (e.g., Claude Code) show promise, they are too generic for database-specific development. They often hallucinate or overlook critical context because database function synthesis is inherently complex and error-prone, where synthesizing a single function may involve registering multiple function units, linking internal references, and implementing logic correctly. To this end, we propose DBCooker, an LLM-based system for automatically synthesizing database native functions. It consists of three components. First, the function characterization module aggregates multi-source declarations, identifies function units that require specialized coding, and traces cross-unit dependencies. Second, we design operations to address the main synthesis challenges: (1) a pseudo-code-based coding plan generator that constructs structured implementation skeletons by identifying key elements such as reusable referenced functions; (2) a hybrid fill-in-the-blank model guided by probabilistic priors and component awareness to integrate core logic with reusable routines; and (3) three-level progressive validation, including syntax checking, standards compliance, and LLM-guided semantic verification. Finally, an adaptive orchestration strategy unifies these operations with existing tools and dynamically sequences them via the orchestration history of similar functions. Results show that DBCooker outperforms other methods on SQLite, PostgreSQL, and DuckDB (34.55% higher accuracy on average), and can synthesize new functions absent in the latest SQLite (v3.50).

机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。

↑