A Relational Database Management System (RDBMS) is one of the fundamental software that supports a wide range of applications, making it critical to identify bugs within these systems. There has been active research on testing RDBMS, most of which employ crash or use metamorphic relations as the oracle. Although existing approaches can detect bugs in RDBMS, they are far from comprehensively evaluating the RDBMS's correctness (i.e., with respect to the semantics of SQL). In this work, we propose a method to test the semantic conformance of RDBMS i.e., whether its behavior respects the intended semantics of SQL. Specifically, we have formally defined the semantics of SQL and implemented them in Prolog. Then, the Prolog implementation serves as the reference RDBMS, enabling differential testing on existing RDBMS. We applied our approach to four widely-used and thoroughly tested RDBMSs, i.e., MySQL, TiDB, SQLite, and DuckDB. In total, our approach uncovered 19 bugs and 11 inconsistencies, which are all related to violating the SQL specification or missing/unclear specification, thereby demonstrating the effectiveness and applicability of our approach.
翻译:关系数据库管理系统(RDBMS)是支撑广泛应用程序的基础软件之一,因此识别这些系统中的错误至关重要。已有大量针对RDBMS测试的活跃研究,其中多数采用崩溃检测或利用蜕变关系作为预言机制。尽管现有方法能够检测RDBMS中的错误,但远未实现对RDBMS正确性(即是否符合SQL语义)的全面评估。本研究提出一种测试RDBMS语义一致性的方法,即验证其行为是否遵循SQL的预期语义。具体而言,我们形式化定义了SQL语义并在Prolog中实现。随后,该Prolog实现作为参考RDBMS,支持对现有RDBMS进行差分测试。我们将该方法应用于四个经过充分测试的常用RDBMS:MySQL、TiDB、SQLite和DuckDB。总计发现19个错误和11处不一致现象,均涉及违反SQL规范或规范缺失/表述不清,从而验证了本方法的有效性与适用性。