GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Feat: Integrating DQE Testing Approaches into SQLancer first in MySQL by luliqwerty · Pull Request #1251 · sqlancer/sqlancer

Conversation

@luliqwerty

@luliqwerty 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:

  1. DQEBase.class: defines the core logic of DQE, including the addition and deletion of auxiliary columns, and the comparison of query results.

  2. SQLQueryError.java: provide standardized error representation and comparison functionality for SQL query operations in DQE.

  3. MySQLDQEOracle.class: Inherits from DQEBase and implements the specific logic of executing DQE in MySQL, including generating queries, executing queries, comparing results, etc.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@mrigger

mrigger commented Jun 30, 2025

Copy link
Copy Markdown
Contributor

Thanks, that's great! Some high-level comments first:

  • for the SQLQueryError, this looks quite similar to ExpectedErrors. Do we really need this class or can we combine these classes?
  • for statements like UPDATE, DELETE, and ALTER TABLE, do you think we can use and extend the generator classes rather than implementing the logic in the DQE oracle?
luliqwerty reacted with eyes emoji
All reactions
  • 👀 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@luliqwerty

luliqwerty commented Jul 1, 2025

Copy link
Copy Markdown
Contributor Author

Thanks, that's great! Some high-level comments first:

  • for the SQLQueryError, this looks quite similar to ExpectedErrors. Do we really need this class or can we combine these classes?
  • for statements like UPDATE, DELETE, and ALTER TABLE, do you think we can use and extend the generator classes rather than implementing the logic in the DQE oracle?

Regarding the SQLQueryError and ExpectedErrors classes, while they do share some surface-level similarities, I think it's important to highlight that their purposes and usage patterns are quite different in practice:

  • SQLQueryError is specifically designed to represent actual errors returned by the database, with structured fields like error level, code, and message. It plays a crucial role in DQE logic to distinguish between different types of errors returned by statements such as UPDATE, SELECT, or DELETE.
  • On the other hand, ExpectedErrors serves as a declarative mechanism for defining acceptable errors during testing, primarily relying on substring or regex-based matching. It does not require the same level of structural detail as SQLQueryError.

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

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@JensonSung

JensonSung commented Jul 1, 2025

Copy link
Copy Markdown
Contributor

I think current implementation is good but specialized for DQE method.

luliqwerty reacted with thumbs up emoji
All reactions
  • 👍 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@JensonSung

JensonSung commented Jul 1, 2025

Copy link
Copy Markdown
Contributor

Thanks, that's great! Some high-level comments first:

  • for the SQLQueryError, this looks quite similar to ExpectedErrors. Do we really need this class or can we combine these classes?
  • for statements like UPDATE, DELETE, and ALTER TABLE, do you think we can use and extend the generator classes rather than implementing the logic in the DQE oracle?

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.
Second, it seems that every kind of statements like update and delete deserve a proper generator, preparing for new testing methods.
These two improvements can be put on the agenda.

luliqwerty reacted with thumbs up emoji
All reactions
  • 👍 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@luliqwerty
luliqwerty deleted the branch sqlancer:main July 4, 2025 12:56
@luliqwerty luliqwerty closed this Jul 4, 2025
@luliqwerty
luliqwerty deleted the main branch July 4, 2025 12:56
@luliqwerty
luliqwerty restored the main branch July 4, 2025 12:57
@luliqwerty luliqwerty reopened this Jul 4, 2025
mrigger
mrigger reviewed Jul 6, 2025
View reviewed changes
Comment thread src/sqlancer/common/query/SQLQueryAdapter.java Resolved

Uh oh!

There was an error while loading. Please reload this page.

mrigger
mrigger reviewed Jul 6, 2025
View reviewed changes
Comment thread src/sqlancer/common/query/SQLQueryError.java Resolved

Uh oh!

There was an error while loading. Please reload this page.

mrigger
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()) {

@mrigger mrigger Jul 6, 2025

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the expression generator already has methods for generating ORDER BYs, so we should try to re-use those. Could we perhaps also re-use or factor out components from the random query generator?

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@luliqwerty luliqwerty Jul 13, 2025

Copy link
Copy Markdown
Contributor Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have add some tests for your mentioned method generateOrderBys() but I got some unexpected errors my repo commit. Sometimes test can't pass with many errors, sometimes this method generated statement like EXISTS (SELECT 1 WHERE FALSE) DESC, which never return rows in SQL statement. I don't know if the methed have some logic errors, or maybe my test have some wrongs, can you give me some suggestions? Thank you very much.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@JensonSung JensonSung Jul 13, 2025

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe only generating columns in order by expressions is enough for applying DQE, which can identify the correctness of complex expressions through WHERE clauses.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

luliqwerty reacted with thumbs up emoji
All reactions
  • 👍 1 reaction
mrigger
mrigger reviewed Jul 6, 2025
View reviewed changes
Comment thread src/sqlancer/mysql/oracle/MySQLDQEOracle.java Resolved

Uh oh!

There was an error while loading. Please reload this page.

mrigger
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) {

@mrigger mrigger Jul 6, 2025

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we have some auxiliary methods for fetching rows (used by other test oracles). Can we perhaps re-use any of these here?

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@JensonSung JensonSung Jul 22, 2025

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@luliqwerty Try to find if we can re-use some auxiliary methods for fetching rows in other test oracles.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

luliqwerty reacted with eyes emoji
All reactions
  • 👀 1 reaction

@luliqwerty luliqwerty Aug 2, 2025

Copy link
Copy Markdown
Contributor Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hello @mrigger @JensonSung
I can't find a suitable method to get rows you mentioned. The confusing method is CERTOracle.getRow(), which is used to get the count of rows. Can you give me some advice or maybe we can just use the way I used to do.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@mrigger mrigger Aug 7, 2025

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think there could be one in https://github.com/sqlancer/sqlancer/blob/main/src/sqlancer/ComparatorHelper.java. If not, we could stick to the current implementation.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

luliqwerty reacted with thumbs up emoji luliqwerty reacted with hooray emoji
All reactions
  • 👍 1 reaction
  • 🎉 1 reaction

@JensonSung JensonSung Aug 8, 2025

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Current implementation can reuse the method getResultSetFirstColumnAsString.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
mrigger
mrigger reviewed Jul 6, 2025
View reviewed changes
Comment thread src/sqlancer/common/oracle/DQEBase.java Resolved

Uh oh!

There was an error while loading. Please reload this page.

mrigger
mrigger reviewed Jul 6, 2025
View reviewed changes
Comment thread src/sqlancer/mysql/oracle/MySQLDQEOracle.java Resolved

Uh oh!

There was an error while loading. Please reload this page.

@mrigger

mrigger commented Jul 6, 2025

Copy link
Copy Markdown
Contributor

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.

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.

luliqwerty reacted with thumbs up emoji
All reactions
  • 👍 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@luliqwerty luliqwerty mentioned this pull request Jul 9, 2025
Add the SQLQueryError class for DQE and its test #1257
Merged
@luliqwerty
luliqwerty force-pushed the main branch from 73507fe to 470a5d7 Compare August 3, 2025 10:10
@luliqwert
Introduce DQE for MySQL in SQLancer and add test to workflow
6c8166b
@luliqwerty
luliqwerty force-pushed the main branch from 470a5d7 to 6c8166b Compare August 3, 2025 11:35
mrigger
mrigger reviewed Aug 7, 2025
View reviewed changes

@mrigger mrigger left a comment

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

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?

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread src/sqlancer/common/query/SQLancerResultSet.java Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread src/sqlancer/mysql/oracle/MySQLDQEOracle.java Resolved

Uh oh!

There was an error while loading. Please reload this page.

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) {

@mrigger mrigger Aug 7, 2025

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think there could be one in https://github.com/sqlancer/sqlancer/blob/main/src/sqlancer/ComparatorHelper.java. If not, we could stick to the current implementation.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

luliqwerty reacted with thumbs up emoji luliqwerty reacted with hooray emoji
All reactions
  • 👍 1 reaction
  • 🎉 1 reaction
Comment thread src/sqlancer/mysql/oracle/MySQLDQEOracle.java 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<>();

@mrigger mrigger Aug 7, 2025

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some of the code seems identical to the one above for the update case. Can we factor those out?

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@sayJason sayJason Aug 8, 2025

Copy link
Copy Markdown

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, some methods could be extracted for fetching these helper columns, like fetching rowID. @luliqwerty

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@luliqwerty luliqwerty Aug 8, 2025

Copy link
Copy Markdown
Contributor Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mrigger you are right, thanks a lot, I've reused the existing method.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@JensonSung

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

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

luliqwert added 3 commits August 8, 2025 14:01
@luliqwert
Fix: remove MySQL specific logic and reuse existing method
1f64426
@luliqwert
refactor(MySQLDQEOracle): extract duplicated code as method
83cf899
@luliqwert
refactor(MySQLDQEOracle): run mvn formatter:format
e1b5861
mrigger
mrigger reviewed Aug 10, 2025
View reviewed changes

@mrigger mrigger left a comment

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

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!

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

luliqwerty and JensonSung reacted with hooray emoji
All reactions
  • 🎉 2 reactions
Comment thread src/sqlancer/common/oracle/DQEBase.java Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread src/sqlancer/common/oracle/DQEBase.java Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread src/sqlancer/common/oracle/DQEBase.java Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread src/sqlancer/mysql/oracle/MySQLDQEOracle.java Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread src/sqlancer/mysql/oracle/MySQLDQEOracle.java Resolved

Uh oh!

There was an error while loading. Please reload this page.

@luliqwert
refactor: fix some code style
131febb
- DQEBase: remove unnecessary method
- MySQLDQEOracle: simplify adding expectedErrors
- MySQLErrors: add a expectedErrors
@JensonSung

JensonSung commented Aug 11, 2025

Copy link
Copy Markdown
Contributor

Good jobs @luliqwerty . LGTM. Happy to merge @mrigger .

luliqwerty reacted with laugh emoji mrigger reacted with rocket emoji
All reactions
  • 😄 1 reaction
  • 🚀 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@mrigger

mrigger commented Aug 11, 2025

Copy link
Copy Markdown
Contributor

Agreed, lgtm, thanks a lot!

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@mrigger
mrigger merged commit 061a337 into sqlancer:main Aug 11, 2025
@mrigger

mrigger commented Aug 11, 2025

Copy link
Copy Markdown
Contributor

I just noticed that when executing the tests, there seems to be an issue:

[INFO] -------------------------------------------------------
[INFO]  T E S T S
[INFO] -------------------------------------------------------
[INFO] Running sqlancer.dbms.TestMySQLDQE
java.sql.SQLNonTransientConnectionException: No operations allowed after connection closed.
	at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:110)
	at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:97)
	at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:89)
	at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:63)
	at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:73)

Could you check whether you can reproduce this locally? This subsequently also results in a crash.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@luliqwerty

luliqwerty commented Aug 13, 2025

Copy link
Copy Markdown
Contributor Author

I just noticed that when executing the tests, there seems to be an issue:

[INFO] -------------------------------------------------------
[INFO]  T E S T S
[INFO] -------------------------------------------------------
[INFO] Running sqlancer.dbms.TestMySQLDQE
java.sql.SQLNonTransientConnectionException: No operations allowed after connection closed.
	at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:110)
	at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:97)
	at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:89)
	at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:63)
	at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:73)

Could you check whether you can reproduce this locally? This subsequently also results in a crash.

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

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@JensonSung

JensonSung commented Aug 13, 2025

Copy link
Copy Markdown
Contributor

I just noticed that when executing the tests, there seems to be an issue:

[INFO] -------------------------------------------------------
[INFO]  T E S T S
[INFO] -------------------------------------------------------
[INFO] Running sqlancer.dbms.TestMySQLDQE
java.sql.SQLNonTransientConnectionException: No operations allowed after connection closed.
	at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:110)
	at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:97)
	at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:89)
	at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:63)
	at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:73)

Could you check whether you can reproduce this locally? This subsequently also results in a crash.

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

It seems to be a crash bug. I run DQE locally in SQLancer, which executes without such errors.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@mrigger

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.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@mrigger

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 README.md.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@JensonSung

JensonSung commented Aug 22, 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.

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.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@luliqwerty luliqwerty mentioned this pull request Sep 2, 2025
feat(DQE): Add Extensibility to DQE #1272
Merged
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@mrigger mrigger mrigger left review comments
+2 more reviewers
@sayJason sayJason sayJason left review comments
@JensonSung JensonSung JensonSung left review comments
Reviewers whose approvals may not affect merge requirements

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

5 participants

@luliqwerty @mrigger @JensonSung @sayJason @luliqwert
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.