Title: Integrate C-Reduce for Automatic Test Case Reduction · Issue #1241 · sqlancer/sqlancer · GitHub
Open Graph Title: Integrate C-Reduce for Automatic Test Case Reduction · Issue #1241 · sqlancer/sqlancer
X Title: Integrate C-Reduce for Automatic Test Case Reduction · Issue #1241 · sqlancer/sqlancer
Description: Problem Statement Currently, SQLancer users must manually capture database states and write interestingness scripts when using C-Reduce for test case minimization. This process is error-prone and limits automation capabilities. Implement...
Open Graph Description: Problem Statement Currently, SQLancer users must manually capture database states and write interestingness scripts when using C-Reduce for test case minimization. This process is error-prone and l...
X Description: Problem Statement Currently, SQLancer users must manually capture database states and write interestingness scripts when using C-Reduce for test case minimization. This process is error-prone and l...
Opengraph URL: https://github.com/sqlancer/sqlancer/issues/1241
X: @github
Domain: patch-diff.githubusercontent.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Integrate C-Reduce for Automatic Test Case Reduction","articleBody":"### Problem Statement\n\nCurrently, SQLancer users must manually capture database states and write interestingness scripts when using C-Reduce for test case minimization. This process is error-prone and limits automation capabilities.\n\n### Implementation Plan\n\n1. **Add CLI option (`MainOptions.java`):**\n\n```java\n@Parameter(names = \"--use-creduce\", description = \"EXPERIMENTAL Attempt to reduce queries using c-reduce\")\nprivate boolean useCReduce = false; // NOPMD\n```\n\n2. **Modify Exception Handling (`Main.java`):**\n\nInside `executeMain(...)`: extend the existing `catch (Throwable reduce)` block.\n\n```java\ntry {\n ...\n} catch (Throwable reduce) {\n reduce.printStackTrace();\n executor.getStateToReproduce().exception = reduce.getMessage();\n executor.getLogger().logFileWriter = null;\n executor.getLogger().logException(reduce, executor.getStateToReproduce());\n \n if (options.useCreduce()) {\n Reducer\u003cG\u003e reducer = new CReducer\u003c\u003e(provider);\n creducer.reduce(/* state, reduce, ... */);\n }\n return false;\n}\n```\n\n3. **CReducer.reduce(...) should:**\n - Generate `databasex.sql`: Dump all statements from `state.getStatements()`, and append the failing statement (from `reduce.detailMessage`)\n - Generate `databasex.sh` (interestingness script): Extract the error substring from `reduce.cause.detailMessage` (e.g., from `[SQLITE_CORRUPT] The database disk image is malformed (database disk image is malformed)` grab `database disk image is malformed`), then can generate a script like: `sqlite3 databasex.sql 2\u003e\u00261 | grep -zq \"database disk image is malformed\"`.\n - Invoke C-reduce by `ProcessBuilder`, like: `Process p = new ProcessBuilder(\"creduce\", \"databasex.sh\", \"databasex.sql\").start();`.\n\n### Questions\n\n- Is this design sensible? Any obvious pitfalls?\n- How to handle missing or mismatched SQLite versions? The interestingness script may fail.\n- This approach only works for SQLite. How can we generalize it to support other DBMSs?\n\n@mrigger @KabilanMA Could you review this design before implementation? Thanks!","author":{"url":"https://github.com/jinhuix","@type":"Person","name":"jinhuix"},"datePublished":"2025-06-06T06:58:55.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":5},"url":"https://github.com/1241/sqlancer/issues/1241"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:28a4c03b-6df9-8d7b-fbb5-ac9d87921451 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 9C74:38B81A:362D7AF:49359C5:6970764A |
| html-safe-nonce | 151d03fa12ecd32d0c162365a7efe498479746b970233ec1fd41eaad1cdf1fa0 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5Qzc0OjM4QjgxQTozNjJEN0FGOjQ5MzU5QzU6Njk3MDc2NEEiLCJ2aXNpdG9yX2lkIjoiMjk3NjgxODE1NjQ3MTg3NTE0NyIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 767fe82916558a6b21cfeb32f93169cfe56725fb46f87dddb2b3fbf716311151 |
| hovercard-subject-tag | issue:3123846540 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/sqlancer/sqlancer/1241/issue_layout |
| twitter:image | https://opengraph.githubassets.com/c856a3583183897d1e2758fbd31adec1c131dfe3f4ea89755d3a5cc4d7ee0df6/sqlancer/sqlancer/issues/1241 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/c856a3583183897d1e2758fbd31adec1c131dfe3f4ea89755d3a5cc4d7ee0df6/sqlancer/sqlancer/issues/1241 |
| og:image:alt | Problem Statement Currently, SQLancer users must manually capture database states and write interestingness scripts when using C-Reduce for test case minimization. This process is error-prone and l... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | jinhuix |
| hostname | github.com |
| expected-hostname | github.com |
| None | 9920a62ba22d06470388e2904804fb7e5ec51c9e35f81784e9191394c74b2bd2 |
| turbo-cache-control | no-preview |
| go-import | github.com/sqlancer/sqlancer git https://github.com/sqlancer/sqlancer.git |
| octolytics-dimension-user_id | 63091257 |
| octolytics-dimension-user_login | sqlancer |
| octolytics-dimension-repository_id | 252650176 |
| octolytics-dimension-repository_nwo | sqlancer/sqlancer |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 252650176 |
| octolytics-dimension-repository_network_root_nwo | sqlancer/sqlancer |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 7d6181066430cc06553c8396ca201e194ae33cb9 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width