We present a number of first- and second-order extensions to SMT theories specifically aimed at representing and analyzing SQL queries with join, projection, and selection operations. We support reasoning about SQL queries with either bag or set semantics for database tables. We provide the former via an extension of a theory of finite bags and the latter via an extension of the theory of finite relations. Furthermore, we add the ability to reason about tables with null values by introducing a theory of nullable sorts based on an extension of the theory of algebraic datatypes. We implemented solvers for these theories in the SMT solver cvc5 and evaluated them on a set of benchmarks derived from public sets of SQL equivalence problems.
翻译:我们提出了一系列针对表示和分析包含连接、投影和选择操作的SQL查询的一阶与二阶SMT理论扩展。我们支持对采用包语义或集合语义的数据库表进行SQL查询推理。前者通过有限包理论的扩展实现,后者通过有限关系理论的扩展实现。此外,我们通过基于代数数据类型理论扩展的可空类型理论,引入了对包含空值表的推理能力。我们在SMT求解器cvc5中实现了这些理论的求解器,并在源自公开SQL等价问题集的基准测试上进行了评估。