Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

execute didn't work when SQL ends with a comment #72

Merged
merged 1 commit into from
Mar 21, 2024

Conversation

gschlager
Copy link
Collaborator

Calling execute with SQL like the following didn't work:

INSERT INTO t (x, y, z) VALUES (7, 7, 7);
INSERT INTO t (x, y, z) VALUES (8, 8, 8);
-- this is a comment at the end

Executing that SQL results in a Extralite::Error: not an error error because prepare_multi_stmt_impl can set stmt to NULL when SQL ends with a comment. The documentation for sqlite3_prepare_v2 states:

If the input text contains no SQL (if the input is an empty string or a comment) then *ppStmt is set to NULL.

Calling `execute` with SQL like the following didn't work:

```
INSERT INTO t (x, y, z) VALUES (7, 7, 7);
INSERT INTO t (x, y, z) VALUES (8, 8, 8);
-- this is a comment at the end
```

Executing that SQL results in a `Extralite::Error: not an error` error because `prepare_multi_stmt_impl` can set `stmt` to `NULL` when SQL ends with a comment. The documentation for `sqlite3_prepare_v2` states:

> If the input text contains no SQL (if the input is an empty string or a comment) then *ppStmt is set to NULL.
@noteflakes
Copy link
Contributor

Great fix, thanks @gschlager !

@noteflakes noteflakes merged commit add4a8c into main Mar 21, 2024
28 checks passed
@gschlager gschlager deleted the fix-execute-comment branch March 21, 2024 09:20
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