Skip to content

Fix panic when querying input with no SQL (only comments/whitespace)#1392

Merged
mattn merged 1 commit into
masterfrom
fix-issue-1390-query-comment-panic
Apr 29, 2026
Merged

Fix panic when querying input with no SQL (only comments/whitespace)#1392
mattn merged 1 commit into
masterfrom
fix-issue-1390-query-comment-panic

Conversation

@mattn

@mattn mattn commented Apr 29, 2026

Copy link
Copy Markdown
Owner

sqlite3_prepare_v2 returns SQLITE_OK with a NULL statement handle when the input contains no SQL (only whitespace or comments). (*SQLiteConn).exec() already handled this case, but (*SQLiteConn).query() forwarded the NULL handle to bind(), which crashed in sqlite3_clear_bindings(NULL).

query() now skips NULL statements like exec() does, and SQLiteRows is made safe against a nil underlying statement so the empty-rows return value does not crash on Next/Columns/DeclTypes.

Closes #1390

sqlite3_prepare_v2 returns SQLITE_OK with a NULL statement handle when
the input contains no SQL. exec() already handled this; query() forwarded
the NULL handle to bind(), which crashed in sqlite3_clear_bindings(NULL).

Make query() skip NULL statements like exec() does, and make SQLiteRows
safe against a nil underlying statement so the empty-rows return value
does not crash.

Closes #1390
@mattn mattn merged commit c719e20 into master Apr 29, 2026
20 checks passed
@mattn mattn deleted the fix-issue-1390-query-comment-panic branch April 29, 2026 07:13
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.

Segmentation violation when querying with just a comment

1 participant