-
-
Notifications
You must be signed in to change notification settings - Fork 411
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
unsafe mode #367
unsafe mode #367
Conversation
Is this something you would consider merging? |
I think this is good solution for those who need the functionality. Thanks for contributing. I'll accept it when there are tests and documentation. |
testers!
|
@@ -64,7 +64,7 @@ void ThrowRangeError(const char* message) { EasyIsolate; isolate->ThrowException | |||
if (db->busy) \ | |||
return ThrowTypeError("This database connection is busy executing a query") | |||
#define REQUIRE_DATABASE_NO_ITERATORS(db) \ | |||
if (db->iterators) \ | |||
if (db->iterators && !db->unsafe_mode) \ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it makes sense that unsafe
also affects the case above, not just the iterators
case. E.g. to allow things such as #338
And what about locked
? Which use-case does that prevent and could this be disabled in unsafe mode as well?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please provide a test case which demonstrates the functionality and I'll include it.
@JoshuaWise could you elaborate what use-case |
I've added a test for my specific use-case in 7ad0b19 I would not suggest to anyone that they write to the same table they are iterating over unless they are 100% sure of what they are doing. I'm personally willing to do this because my database is 40GB+ and I don't want to copy it. In most cases it is preferable to use safe mode and simply copy the database, read from one and insert into the other. Please be very careful when using |
It protects against the example you gave, but it also protects against iterating a statement while already iterating that statement. I'll have to look over all this discussion when I have more time. Hopefully I won't keep you waiting too long! |
@jeromew, @missinglink thank you, this is the 5th SQLite library I have tried to use in the last few days (3 on deno, 2 on nodejs - most dying on a mere 8GB file or this issue). Did you consider adding a note to the "TypeError: This database connection is busy executing a query" that unsafe mode will (dangerously) fix the issue? Might help with some frustration. |
this draft PR addresses some of the concerns in #203
it still requires: user testing, feedback and additional nodejs tests.
unsafe mode can be enabled by setting
{ unsafe: true }
when creating the db connection.this PR can be tested by adding a
postinstall
script to yourpackage.json