⚡ Sangsakala Proxy 🏠 Home
Skip to content

Fix SQLite provider crashes and foreign-key error handling - #1372

Open
yyssophie wants to merge 4 commits into
sqlancer:mainfrom
yyssophie:fix/sqlite3-provider-crashes
Open

yyssophie wants to merge 4 commits into
sqlancer:mainfrom
yyssophie:fix/sqlite3-provider-crashes

Conversation

@yyssophie

@yyssophie yyssophie commented Oct 20, 2026 •

Copy link
Copy Markdown

Summary

Fix three failure modes in the SQLite provider that were found during query-plan-guidance runs:

  • Parse schema column definitions at top-level commas only. Commas inside nested expressions, constraints, and quoted values no longer desynchronize column metadata, and schema objects whose reported columns outnumber parsed definitions no longer cause an ArrayIndexOutOfBoundsException.
  • Use getRandomTableOrBailout when generating DELETE statements so SQLancer skips the action when no writable table is available instead of selecting from an empty list.
  • Treat [SQLITE_CONSTRAINT_FOREIGNKEY] as an expected insert/update error instead of reporting a valid SQLite constraint failure as an assertion failure.

Regression tests

  • Cover nested and quoted commas in schema definitions.
  • Reconstruct a schema containing a view without an explicit column list; this test reproduces the original ArrayIndexOutOfBoundsException on the parent commit.
  • Verify that DELETE generation bails out when only a view is available.
  • Verify that SQLite foreign-key constraint errors are recognized as expected.

Testing

  • mvn -q -Dtest=sqlancer.sqlite3.TestSQLite3Errors,sqlancer.sqlite3.gen.dml.TestSQLite3DeleteGenerator,sqlancer.sqlite3.schema.TestSQLite3Schema test
  • mvn -q -DskipTests verify

@yyssophie
yyssophie marked this pull request as draft October 20, 2026 01:15
@yyssophie yyssophie changed the title Fix crashes in SQLite provider Fix SQLite provider crashes and foreign-key error handling Oct 20, 2026
@yyssophie
yyssophie marked this pull request as ready for review October 20, 2026 01:30

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟡 Changes recommended

Unresolved moderate issues remain in DELETE foreign-key handling and schema parsing of constraints, quoted identifiers, and comments.

1 open issue
What changed in this PR

Fixes SQLite provider crashes and foreign-key error handling.

Changes:

  • Improves schema definition parsing.
  • Prevents DELETE generation when no writable table exists.
  • Recognizes foreign-key constraint errors.
  • Adds regression coverage.
File Summary
test/​sqlancer/​sqlite3/​TestSQLite3Errors.java Tests expected SQLite errors.
test/​sqlancer/​sqlite3/​schema/​TestSQLite3Schema.java Tests schema parsing and views.
test/​sqlancer/​sqlite3/​gen/​dml/​TestSQLite3DeleteGenerator.java Tests DELETE bailout behavior.
src/​sqlancer/​sqlite3/​SQLite3Errors.java Adds foreign-key error handling.
src/​sqlancer/​sqlite3/​schema/​SQLite3Schema.java Parses schema definitions safely.
src/​sqlancer/​sqlite3/​gen/​dml/​SQLite3DeleteGenerator.java Handles missing writable tables.

Review effort: Lite

*/
static List<String> splitColumnDefinitions(String sql) {
List<String> definitions = new ArrayList<>();
int opening = sql.indexOf('(');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants