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 — Support CODDTest in sqlancer by DerZc · Pull Request #1054 · sqlancer/sqlancer

Conversation

@DerZc

@DerZc DerZc commented Jan 5, 2025

Copy link
Copy Markdown
Contributor

No description provided.

Sorry, something went wrong.

Uh oh!

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

All reactions
DerZc added 11 commits January 3, 2025 20:02
@DerZc
add the implementation of CODDTest for SQLite3
6b86175
@DerZc
fix a typo and remove some redundant code of CODDTest for sqlite3
c6f2c4a
@DerZc
add CODDTest for DuckDB
7a754ba
@DerZc
Merge remote-tracking branch 'upstream/main'
f18638e
@DerZc
enable CTE and insert test in CODDTest for DuckDB
5db6e3c
@DerZc
support CODDTest for CockroachDB
dbd8c89
@DerZc
fix some false positive in CODDTest for DuckDB
0a8f9a1
@DerZc
fix the false positive in CODDTest for SQLite
9596426
@DerZc
remove a piece of redundant code
d4e0f8f
@DerZc
remove some radundant log code in CODDTest for CockroachDB
4122731
@DerZc
support CODDTest for TiDB
bc53382
mrigger
mrigger reviewed Jan 19, 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.

Thanks for the PR! Added some initial comments. I think it's quite challenging to review such a large PR. Do you think we could split it into multiple smaller ones (referencing this as the main PR)? For example, as a first step, we could add some of the new expression nodes and the visit methods.

Sorry, something went wrong.

Uh oh!

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

All reactions
Comment thread src/sqlancer/cockroachdb/CockroachDBOptions.java
public int maxNumIndexes = 20;

@Parameter(names = { "--coddtest-model" }, description = "Apply CODDTest on expression, subquery, or random")
public String coddTestModel = "random";

@mrigger mrigger Jan 19, 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.

Perhaps we could use a similar strategy as the TLP oracles where we have separate enums?

Sorry, something went wrong.

Uh oh!

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

All reactions
Comment thread src/sqlancer/cockroachdb/CockroachDBToStringVisitor.java Outdated
}
sb.append(", ");
}
sb.deleteCharAt(sb.length() - 1);

@mrigger mrigger Jan 19, 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.

Deleting previous parts seems quite complicated. Can we simplify this (and similar logic in other files)?

Sorry, something went wrong.

Uh oh!

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

All reactions
Comment thread src/sqlancer/cockroachdb/ast/CockroachDBConstant.java
}

@Override
public String toStringForComparison() {

@mrigger mrigger Jan 19, 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.

This seems quite complicated. Can we simplify and/or document this?

Sorry, something went wrong.

Uh oh!

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

All reactions
Comment thread src/sqlancer/cockroachdb/ast/CockroachDBWithClasure.java Outdated
@@ -0,0 +1,24 @@
package sqlancer.cockroachdb.ast;

public class CockroachDBWithClasure implements CockroachDBExpression {

@mrigger mrigger Jan 19, 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.

What does the name mean?

Sorry, something went wrong.

Uh oh!

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

All reactions
Comment thread src/sqlancer/duckdb/DuckDBErrors.java Outdated
errors.add("must appear in the GROUP BY clause or be used in an aggregate function");
errors.add("must appear in the GROUP BY clause or must be part of an aggregate function");
errors.add("GROUP BY term out of range - should be between");
errors.add("INTERNAL Error: Failed to bind column reference");

@mrigger mrigger Jan 19, 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.

Internal errors are bugs, so we should not ignore them.

Sorry, something went wrong.

Uh oh!

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

All reactions
Comment thread src/sqlancer/duckdb/ast/DuckDBConstantWithType.java Outdated
import sqlancer.duckdb.DuckDBSchema.DuckDBCompositeDataType;
import sqlancer.duckdb.ast.DuckDBConstant.DuckDBNullConstant;

public class DuckDBConstantWithType implements DuckDBExpression {

@mrigger mrigger Jan 19, 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.

Can we achieve the same with a cast expression to which we pass a constant?

Sorry, something went wrong.

Uh oh!

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

All reactions
Comment thread src/sqlancer/sqlite3/ast/SQLite3Expression.java
}
}

public static class SQLite3ExpressionBag extends SQLite3Expression {

@mrigger mrigger Jan 19, 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.

For some of the newly added classes, it's not immediately clear what this looks like at a SQL level. would it be possible to add a comment for such cases?

Sorry, something went wrong.

Uh oh!

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

All reactions
DerZc added 8 commits March 4, 2025 15:45
@DerZc
support mysql
e9f1418
@DerZc
fix a typo
412f69e
@DerZc
add comments for ExpressionBag
2d74254
@DerZc
remove deleteCharAt to simplify code logic
9db8ae0
@DerZc
modify DuckDBConstantWithType to DuckDBTypeCast
9581dbb
@DerZc
remove an internel error from the ignore list
f99cc40
@DerZc
handle confilct in MySQL
6343041
@DerZc
Merge remote-tracking branch 'upstream/main'
3045bad
@DerZc DerZc mentioned this pull request Mar 22, 2025
Support CODDTest for SQLite #1181
Merged
@DerZc DerZc mentioned this pull request Apr 30, 2025
Support CODDTest for DuckDB #1224
Open
fm4v added a commit to fm4v/sqlancer that referenced this pull request May 15, 2026
@fm4v
ClickHouse CERT/CODDTest: align with the papers
752a4fc
The initial CERT and CODDTest implementations diverged from their
papers in ways that defeated the test signal:

CERT was using actual row counts from running the queries and a
bidirectional mutator framework. Per Ba and Rigger, ICSE 2024 the
property under test is `EstCard(Q', D) <= EstCard(Q, D)` -- the
*estimator's* projection, with Q' strictly more restrictive than Q,
and "CERT eschews executing queries". This rewrite:

* Reads cardinality from `EXPLAIN ESTIMATE`, summing `rows` across
  the per-table tuples it returns. The query is never executed.
* Restricts mutations to one direction. `mutateWhere`/`mutateAnd`
  always AND-tighten or introduce a WHERE; `mutateOr` drops an OR
  operand (per the paper's restrictive-OR rule) or falls back to AND;
  `mutateDistinct` only promotes ALL -> DISTINCT. All return
  `increase=false`.
* Skips runs where the estimator returns nothing (non-MergeTree
  engines, `ORDER BY tuple()`, unsupported expressions), and skips
  runs where the structural-similarity gate on `EXPLAIN PLAN` shows
  too much drift.

CODDTest was toggling random optimizer flags via per-query `SETTINGS`
clauses and comparing results. Per Zhang and Rigger, SIGMOD 2025 the
oracle is constant-folding-driven: take a subexpression E in Q,
evaluate E to a value V via an auxiliary query A, build a folded
query F by substituting V for E, then assert results of Q and F are
identical. This rewrite implements the scalar-subquery variant
(same as DuckDBCODDTestOracle in the upstream PR sqlancer#1054):

  aux:    SELECT min(c)/max(c) FROM t                            -> V
  Q:      SELECT * FROM t WHERE col op (SELECT min/max(c) FROM t)
  F:      SELECT * FROM t WHERE col op V

Only `Int32`/`String` columns are folded since they are the only
types the existing schema generator and `ClickHouseSchema.getConstant`
support; NULL auxiliary results are skipped (NULL-propagation would
make the predicate UNKNOWN for every row and the equivalence does
not hold).

Verified locally against a release ClickHouse 26.5 server:

* CERT: ~6 q/s effective (most attempts skip because no estimate
  responds to the random mutation), 0 false positives in a 30s
  window.
* CODDTest: ~22 q/s, 96-97% successful statements, 0 false positives.

`mvn checkstyle:check` clean, `mvn package -Dmaven.test.skip=true`
succeeds.

Papers:
  CERT     https://doi.org/10.1145/3597503.3639076
  CODDTest https://doi.org/10.1145/3709674
@fm4v fm4v mentioned this pull request May 15, 2026
ClickHouse: wrong-result oracle suite (31 oracles), recursive type system, and generator expansion ClickHouse/sqlancer#4
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

At least 1 approving review is required to merge this pull request.

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.

2 participants

@DerZc @mrigger
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.