arXiv:2604.06231cs.DBcs.AI2026-04被引 3

用大模型自动生成数据库原生函数,提升开发效率与准确性。

Automating Database-Native Function Code Synthesis with LLMs

  • 通过多源声明分析与依赖追踪,精准识别函数单元和逻辑结构。
  • 在三个数据库上平均准确率比现有方法高34.55%,能生成新版本未包含的函数。
  • 适合数据库开发者和工具链研究者,尤其关注自动化函数生成场景。

数据库系统不断在内核中引入新功能(即数据库原生函数),以支持新应用和业务迁移。这种增长带来对自动合成数据库原生函数的迫切需求。尽管基于大模型的代码生成(如Claude Code)已有进展,但其通用性难以满足数据库特定开发需求,常出现幻觉或忽略关键上下文。由于数据库函数合成涉及多个函数单元注册、内部引用链接和逻辑正确实现,过程复杂且易出错。为此,我们提出DBCooker,一个基于大模型的自动合成系统,包含三个组件:第一,函数特征化模块整合多源声明,识别需特殊编码的函数单元,并追踪跨单元依赖;第二,设计三项关键技术:(1)基于伪代码的编码计划生成器,构建结构化实现骨架;(2)融合概率先验与组件感知的混合填空模型,整合核心逻辑与可复用组件;(3)三级渐进验证,包括语法检查、标准合规性与大模型引导的语义验证;第三,采用自适应编排策略,结合现有工具并根据相似函数的历史编排动态调度流程。实验表明,DBCooker在SQLite、PostgreSQL和DuckDB上均优于其他方法,平均准确率提升34.55%,并能合成最新SQLite(v3.50)中不存在的新函数。

原文摘要 · Abstract (English)

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).

代码生成数据库大模型

Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。