Skip to content

Detect statement type in Execute SQL despite leading comments - #4233

Open
deepsidhu1313 wants to merge 1 commit into
sqlitebrowser:masterfrom
deepsidhu1313:fix/vacuum-execute-sql
Open

deepsidhu1313 wants to merge 1 commit into
sqlitebrowser:masterfrom
deepsidhu1313:fix/vacuum-execute-sql

Conversation

@deepsidhu1313

Copy link
Copy Markdown
Contributor

RunSql::getQueryType() looked at the start of the statement text, but the text SQLite hands back for a statement includes any comments in front of it. A script like "-- compact\nVACUUM;" was therefore classified as an ordinary statement, wrapped in a savepoint and failed with "cannot VACUUM from within a transaction" (the same applies to VACUUM INTO and to PRAGMA statements that must run outside of a transaction). Skip whitespace and comments before matching the keyword.

Add a test-run-sql target which runs scripts through RunSql against a real database.

RunSql::getQueryType() looked at the start of the statement text, but the
text SQLite hands back for a statement includes any comments in front of
it. A script like "-- compact\nVACUUM;" was therefore classified as an
ordinary statement, wrapped in a savepoint and failed with "cannot VACUUM
from within a transaction" (the same applies to VACUUM INTO and to PRAGMA
statements that must run outside of a transaction). Skip whitespace and
comments before matching the keyword.

Add a test-run-sql target which runs scripts through RunSql against a real
database.

This branch has not been deployed

No deployments
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