Abstract
In recent years, a plethora of database management systems have surfaced to meet the demands of various scenarios. Emerging database systems, such as time-series and streaming database systems, are tailored to specific use cases requiring enhanced functionality and performance. However, as they are typically less mature, there can be bugs that either cause incorrect results or errors impacting reliability. To tackle this, we propose enhanced differential testing to uncover various bugs in emerging SQL-like database systems. The challenge is how to deal with differences of these emerging databases. Our insight is that many emerging database systems are conceptually extensions of relational database systems, making it possible to reveal logic bugs leveraging existing relational, known-reliable database systems. However, due to inevitable syntax or semantics gaps, it remains challenging to scale differential testing to various emerging database systems. We enhance differential testing for emerging database systems with three steps: (i) identifying shared clauses; (ii) extending shared clauses via mapping new features back to existing clauses of relational database systems; and (iii) generating differential inputs using extended shared clauses. We implemented our approach in a tool called SQLxDiff and applied it to four popular emerging database systems. In total, we found 57 unknown bugs, of which 17 were logic bugs and 40 were internal errors. Overall, vendors fixed 50 bugs and confirmed 5. Our results demonstrate the practicality and effectiveness of SQLxDiff in detecting bugs in emerging database systems, which has the potential to improve the reliability of their applications.
Introduction
The modern database landscape is diversifying rapidly. While traditional relational database management systems (RDBMS) like PostgreSQL remain industry standards, a new generation of "emerging" systems has surfaced to address specialized needs, such as time-series data (e.g., QuestDB, TDEngine) and real-time streaming (e.g., RisingWave). These systems are often developed under intense market pressure, meaning they lack the decades of rigorous "battle-testing" that mature RDBMS have undergone. Consequently, they are prone to both internal errors (crashes) and more insidious logic bugs, where the system returns an incorrect result without alerting the user.
Methodology: The SQLxDiff Framework
To improve the reliability of these systems, we developed SQLxDiff, a tool designed for enhanced differential testing. Traditional differential testing—running the same query on two systems and comparing outputs—often fails when applied to emerging databases because of specialized syntax (e.g., SAMPLE BY or TUMBLE) that a reference database like PostgreSQL cannot interpret.
SQLxDiff overcomes this by implementing a four-stage workflow:
- Clause Identification: Automatically determining which SQL clauses are shared between the target and reference systems.
- Clause Mapping: Defining semantic mappings for unique features (e.g., mapping QuestDB's
LATEST ONto a complex but equivalent standard SQL query). - Query Generation: Randomly generating queries that utilize both shared and mapped clauses to create semantically equivalent inputs for both systems.
- Result Analysis: Executing queries on both systems and comparing results to identify discrepancies.
Bridging the Semantic Gap
The core insight behind SQLxDiff is that most emerging databases are conceptually "Relational+"; they extend the relational model rather than replacing it. By "translating" specialized features back into the language of mature systems, we can use a reliable RDBMS as a "living oracle."
This mapping process significantly expands the "testing surface." Our evaluation showed that mapping just a small number of key clauses (10–20) allowed the tool to cover 20% more unique query plans compared to standard differential testing, effectively bridging the semantic gap between new and established systems.
Evaluation and Results
We evaluated SQLxDiff on four popular emerging systems: QuestDB, TDEngine, RisingWave, and CrateDB, using PostgreSQL as the ground truth. The tool successfully identified 57 previously unknown bugs, including 17 critical logic bugs. The impact was immediate, with vendors fixing 50 of these bugs and confirming another 5. Furthermore, SQLxDiff outperformed state-of-the-art tools like SQLancer in both bug detection rates and code coverage, demonstrating its superior effectiveness in the emerging database domain.
Conclusion and Future Work
SQLxDiff demonstrates that cross-system differential testing is a powerful method for securing emerging database technology. While the current implementation requires some manual effort to define clause mappings, future iterations could leverage Large Language Models (LLMs) to automate this process. By bridging the syntax gap, we can ensure that the next generation of data infrastructure is as reliable as the relational foundations it is built upon.
Summary updated