paperbot · PL 论文追踪

全部论文 待读 收藏

P2 A Formal Framework for Typing and Cast Semantics in SQL Engines

SQL 引擎中类型与类型转换语义的形式化框架
TOPLAS ACM Transactions on Programming Languages and Systems2026匹配度 3/10 · 论文属于 PL/形式语义与类型系统,关注 SQL 引擎的类型安全、隐式转换和工业实现验证,与用户核心方向(静态分析用于 ML/Agentic、LLM/Agent 改进静态分析、浮点或贝叶斯程序分析)没有直接交叉。仅在“兼具形式化与工程实现、工业落地”这一偏好上有一定共鸣,但研究主题不匹配。引用 0 inbox
Wenjia Ye, Matías Toro, Claudio Gutierrez, Bruno C. D. S. Oliveira, Éric Tanter
crossref: 2026-09-10

AI 速览

一句话:提出 TRAF:一种刻画 SQL 静态与动态类型及隐式类型转换的形式化类型语义框架,并给出类型安全条件与五引擎实例化验证。

实际 SQL 引擎在类型约束与隐式类型转换的处理上存在微妙差异,而这些差异通常被 SQL 的形式化研究忽略,直接影响查询在不同引擎间的可移植性。本文提出名为 TRAF 的 SQL 形式化类型语义,用抽象算子同时刻画静态与动态类型行为,从而能够系统性地建模 PostgreSQL、MS SQL Server、MySQL、SQLite 和 Oracle 等引擎的类型与转换行为。作者给出了该形式化体系对类型处理的形式化保证,识别出引擎实例化满足类型安全(type safety)与类型可靠性(type soundness)的实际条件,并指出 TRAF 可作为现有引擎类型行为可显式检验的刻画,指导其演进,并为类型感知查询优化与可证明正确的查询翻译器提供形式化基础。评估方面,作者用 Python 为五个引擎实现了 TRAF,并使用合成查询、SQLancer++ 生成的查询以及改造后的 Spider 与 Calcite 基准查询进行了充分性测试。

问题
不同 SQL 引擎在类型约束和隐式类型转换上的处理差异缺乏形式化刻画,导致查询可移植性难以保证,也阻碍了类型感知优化与查询翻译的正确性论证。
方法
提出 TRAF 形式化类型语义,通过抽象算子统一表达静态与动态类型行为,并为各引擎提供实例化,进而分析其类型安全与类型可靠性的充分条件。
评估
在 Python 中实现 TRAF 并实例化五个主流 SQL 引擎,使用合成查询、SQLancer++ 生成查询以及改造的 Spider 和 Calcite 基准查询检验该形式化框架的充分性。
原文摘要(Abstract)

Practical SQL engines differ in subtle ways in their handling of typing constraints and implicit type casts. These issues, usually not considered in formal accounts of SQL, directly affect the portability of queries between engines. To address this problem, we present a formal typing semantics for SQL, named TRAF , that explicitly captures both static and dynamic type behavior. The system TRAF is expressed in terms of abstract operators that provide the necessary leeway to systematically model the type and cast behavior of different SQL engines (PostgreSQL, MS SQL Server, MySQL, SQLite, and Oracle). We show that this formalism provides formal guarantees for the handling of types. We identify practical conditions under which engine instantiations satisfy type safety and type soundness. In this regard, TRAF can serve as an explicit and testable account of typing in existing engines, potentially guide their evolution, and provide a formal basis to study type-aware query optimizations and design provably-correct query translators. We also test the adequacy of the formalism by implementing TRAF in Python for these five engines and testing it with synthetic queries, SQLancer++- generated queries, and adapted Spider and Calcite benchmark queries.

链接与引用

DOI 原文 ·

BibTeX
@inproceedings{paperbot3949,
  title = {A Formal Framework for Typing and Cast Semantics in SQL Engines},
  author = {Wenjia Ye and Matías Toro and Claudio Gutierrez and Bruno C. D. S. Oliveira and Éric Tanter},
  booktitle = {TOPLAS},
  year = {2026},
  doi = {10.1145/3834861}
}