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

sqlitex.ExecScript fails to run scripts that include statements that cannot be executed within a transaction #111

Open
DrGo opened this issue Jan 2, 2021 · 2 comments
Labels
question Further information is requested

Comments

@DrGo
Copy link

DrGo commented Jan 2, 2021

@crawshaw @AdamSLevy

Currently, ExecScript executes passed script within a SAVEPOINT transaction. This prevents certain commands from running, eg, vacuum, begin. These are commonly used commands in SQL scripts. Should we have a different version that does not automatically SAVEPOINT?

Thanks,

@AdamSLevy AdamSLevy added the question Further information is requested label Nov 7, 2021
@AdamSLevy
Copy link
Collaborator

AdamSLevy commented Nov 7, 2021

@DrGo ExecScript runs a SAVEPOINT by design so that scripts can be run atomically. I understand there are certain operations you can't do inside of a transaction such as vacuuming, but why would you want to use BEGIN when you could just use SAVEPOINT or break up your script using the go APIs for nested transactions?

For the one off vacuum, which I generally do after a database migration, I just use sqlitex.Exec instead. Or rather ExecTransient because I don't think its a Stmt worth caching.

Can you expand on the usecase of having an ExecScript-like function that did not use a SAVEPOINT, or an option to not use it?

@boutros
Copy link

boutros commented May 9, 2022

I think perhaps this is the explanation for the issue I opened: #131

So the use case for me is to run a PRAGMA statement on all connections - for example to enforce FOREIGN_KEYS.

I see @DrGo have a solution here which seems reasonable: DrGo@018b243

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

3 participants