Feat: Integrating DQE Testing Approaches into SQLancer first in MySQL by luliqwerty · Pull Request #1251 · sqlancer/sqlancer
Repository navigation
Feat: Integrating DQE Testing Approaches into SQLancer first in MySQL - #1251
Merged
mrigger merged 5 commits into sqlancer:main from luliqwerty:main Aug 11, 2025
Merged
Feat: Integrating DQE Testing Approaches into SQLancer first in MySQL #1251 mrigger merged 5 commits into sqlancer:main from luliqwerty:main
Conversation
luliqwerty commented Jun 29, 2025
Copy link Copy Markdown
Contributor
This PR is to Integrating DQE (Differential Query Execution) Testing Approaches into SQLancer. More information see DQE paper .
Take MySQL as the first step.
The code is divided into three main parts:
-
DQEBase.class: defines the core logic of DQE, including the addition and deletion of auxiliary columns, and the comparison of query results. -
SQLQueryError.java: provide standardized error representation and comparison functionality for SQL query operations in DQE. -
MySQLDQEOracle.class: Inherits fromDQEBaseand implements the specific logic of executing DQE in MySQL, including generating queries, executing queries, comparing results, etc.
mrigger commented Jun 30, 2025
Copy link Copy Markdown
Contributor
|
Thanks, that's great! Some high-level comments first:
|
luliqwerty commented Jul 1, 2025
Copy link Copy Markdown
Contributor
Author
Regarding the
Given these differences, merging them into a single class could lead to confusion, increased coupling, and reduced clarity in terms of responsibility separation. I believe keeping them separate helps maintain a clean architecture and supports better extensibility in the future. That said, if you have any alternative suggestions or design ideas on how we can better organize this part of the code, I'd be more than happy to discuss them further. Thanks again for your thoughtful feedback! @mrigger @JensonSung |
JensonSung commented Jul 1, 2025
Copy link Copy Markdown
Contributor
|
I think current implementation is good but specialized for DQE method. |
JensonSung commented Jul 1, 2025
Copy link Copy Markdown
Contributor
First, revising ExepctedErrors like SQLQueryError to provide a structured information may help ease to identify errors compared to a string-formed information. While DQE does not distinguish which error is expected but compare whether errors are consistent. A clear name could be required. |
View reviewed changes
mrigger reviewed Jul 6, 2025
View reviewed changes
mrigger reviewed Jul 6, 2025
View reviewed changes
Comment thread src/sqlancer/mysql/oracle/MySQLDQEOracle.java
Outdated
| boolean generateLimit = false; | ||
| int limit = 0; | ||
| if (operateOnSingleTable) { | ||
| if (Randomly.getBooleanWithSmallProbability()) { |
View reviewed changes
mrigger reviewed Jul 6, 2025
View reviewed changes
Comment thread src/sqlancer/mysql/oracle/MySQLDQEOracle.java
Outdated
| String selectRowId = String.format("SELECT %s FROM %s", rowId, tableName); | ||
| SQLancerResultSet resultSet = new SQLQueryAdapter(selectRowId).executeAndGet(state); | ||
| HashSet<String> rows = new HashSet<>(); | ||
| if (resultSet != null) { |
View reviewed changes
mrigger reviewed Jul 6, 2025
View reviewed changes
mrigger commented Jul 6, 2025
Copy link Copy Markdown
Contributor
Okay, then let's leave them separate for now. I guess there is a conceptual commonality (both are about errors returned by the database system), but if that does not (yet) make sense at an implementation level, we could try to address this later. |
73507fe to
470a5d7
Compare
August 3, 2025 10:10
Introduce DQE for MySQL in SQLancer and add test to workflow
6c8166b
luliqwerty
force-pushed
the
main
branch
from
470a5d7 to
6c8166b
Compare
August 3, 2025 11:35 mrigger reviewed Aug 7, 2025
View reviewed changes
mrigger left a comment
Copy link Copy Markdown
Contributor
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more .
This looks close to being merge ready. Could you have another look at my comments? @JensonSung , perhaps you could also do another review then?
Comment thread src/sqlancer/mysql/oracle/MySQLDQEOracle.javaOutdated
| String selectRowId = String.format("SELECT %s FROM %s", rowId, tableName); | ||
| SQLancerResultSet resultSet = new SQLQueryAdapter(selectRowId).executeAndGet(state); | ||
| HashSet<String> rows = new HashSet<>(); | ||
| if (resultSet != null) { |
Outdated
| String rowId = tableName + "." + COLUMN_ROWID; | ||
| String selectRowId = String.format("SELECT %s FROM %s", rowId, tableName); | ||
| SQLancerResultSet resultSet = new SQLQueryAdapter(selectRowId).executeAndGet(state, false); | ||
| HashSet<String> rows = new HashSet<>(); |
JensonSung commented Aug 8, 2025
Copy link Copy Markdown
Contributor
|
Sorry for possible confusing. @sayJason is my another account. I try to use the same one. Any problem, @JensonSung |
Fix: remove MySQL specific logic and reuse existing method
1f64426
refactor(MySQLDQEOracle): extract duplicated code as method
83cf899
refactor(MySQLDQEOracle): run mvn formatter:format
e1b5861
mrigger
reviewed
Aug 10, 2025
View reviewed changes
mrigger left a comment
Copy link Copy Markdown
Contributor
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more .
Just did another quick and noticed some final small requests. Could you please have a last look at them before we merge the PR? Other than that, @JensonSung , do the changes look good to you?
Excited to finally have DQE supported in SQLancer! Thanks a lot, @luliqwerty !
refactor: fix some code style
131febb
- DQEBase: remove unnecessary method - MySQLDQEOracle: simplify adding expectedErrors - MySQLErrors: add a expectedErrors
JensonSung commented Aug 11, 2025
Copy link Copy Markdown
Contributor
|
Good jobs @luliqwerty . LGTM. Happy to merge @mrigger . |
mrigger commented Aug 11, 2025
Copy link Copy Markdown
Contributor
|
Agreed, lgtm, thanks a lot! |
061a337
into
sqlancer : main
Aug 11, 2025
mrigger commented Aug 11, 2025
Copy link Copy Markdown
Contributor
|
I just noticed that when executing the tests, there seems to be an issue:
Could you check whether you can reproduce this locally? This subsequently also results in a crash. |
luliqwerty commented Aug 13, 2025
Copy link Copy Markdown
Contributor
Author
This is an unexpected error, as the CI for the merge commit passed. The error indicates that the code is attempting to execute an SQL operation on a database connection that has already been closed. However, it seems that DQE did not perform this action. @mrigger @JensonSung |
JensonSung commented Aug 13, 2025
Copy link Copy Markdown
Contributor
It seems to be a crash bug. I run DQE locally in SQLancer, which executes without such errors. |
mrigger commented Aug 14, 2025
Copy link Copy Markdown
Contributor
|
Could it be that the local version of MySQL and the one in the CI are different? If they are the same, perhaps it could be helpful to run for DQE a bit longer. It could be that it triggered a crash bug, as pointed out by @JensonSung . |
mrigger commented Aug 14, 2025
Copy link Copy Markdown
Contributor
|
Btw, it would also be great to add DQE as part of the documentation of SQLancer in the table of the main |
JensonSung commented Aug 22, 2025
Copy link Copy Markdown
Contributor
Sorry for the late message. The local MySQL has a different version. I try a bit longer time to run DQE, which runs well and does not report errors. |