-
Notifications
You must be signed in to change notification settings - Fork 200
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
Add statement_timeout=
method
#463
Merged
tenderlove
merged 22 commits into
sparklemotion:main
from
fractaledmind:statement-timeout
Feb 2, 2024
Merged
Changes from all commits
Commits
Show all changes
22 commits
Select commit
Hold shift + click to select a range
6c4e155
Add the progress_handler interface
fractaledmind 046bd67
Add tests for the progress_handler interface
fractaledmind 11a94dc
Merge branch 'main' into progress-handler
fractaledmind 50f1ef0
Remove extra line
fractaledmind c6bf834
Bump the frequency for the opcode arg test
fractaledmind 3681b2a
Bump the frequency for the opcode arg test and make assertion more re…
fractaledmind c0d5144
Only define the ruby progress_handler method if the OMIT compilation …
fractaledmind e3f95ca
Add statement_timeout= method that leverages progress_handler to inte…
fractaledmind 3ebee19
Merge branch 'progress-handler' into statement-timeout
fractaledmind b819265
Add a test for statement_timeout=
fractaledmind 3ba847c
Allow statement_timeout= to accept a nil to reset the progress_handler
fractaledmind 870f3b9
Merge branch 'master' into statement-timeout
fractaledmind bf1f0e6
Implement that statement_timeout= in pure C
fractaledmind c8007e7
Remove old progress_handler tests
fractaledmind ae76a01
Update ext/sqlite3/database.c
fractaledmind cd47d9b
Reset stmt_deadline when preparing a statement
fractaledmind 13d4067
Make test faster
fractaledmind 31e44c1
Merge branch 'main' into statement-timeout
fractaledmind bd0267e
Implement statement_timeout with timespecs
fractaledmind 6456dec
Add the new timespec.h file to the gemspec
fractaledmind 832fe6a
Update test-gem-file-contents
fractaledmind c80aeef
Update ext/sqlite3/database.c
fractaledmind File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
#define timespecclear(tsp) (tsp)->tv_sec = (tsp)->tv_nsec = 0 | ||
#define timespecisset(tsp) ((tsp)->tv_sec || (tsp)->tv_nsec) | ||
#define timespecisvalid(tsp) \ | ||
((tsp)->tv_nsec >= 0 && (tsp)->tv_nsec < 1000000000L) | ||
#define timespeccmp(tsp, usp, cmp) \ | ||
(((tsp)->tv_sec == (usp)->tv_sec) ? \ | ||
((tsp)->tv_nsec cmp (usp)->tv_nsec) : \ | ||
((tsp)->tv_sec cmp (usp)->tv_sec)) | ||
#define timespecsub(tsp, usp, vsp) \ | ||
do { \ | ||
(vsp)->tv_sec = (tsp)->tv_sec - (usp)->tv_sec; \ | ||
(vsp)->tv_nsec = (tsp)->tv_nsec - (usp)->tv_nsec; \ | ||
if ((vsp)->tv_nsec < 0) { \ | ||
(vsp)->tv_sec--; \ | ||
(vsp)->tv_nsec += 1000000000L; \ | ||
} \ | ||
} while (0) | ||
#define timespecafter(tsp, usp) \ | ||
(((tsp)->tv_sec > (usp)->tv_sec) || \ | ||
((tsp)->tv_sec == (usp)->tv_sec && (tsp)->tv_nsec > (usp)->tv_nsec)) | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Isn't
timespec.h
available on some platforms? I thought we'd conditionally define this stuff depending on platform availability.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.
TBH, I wasn't sure how best to handle this. Is there a single header file I can try to include that will have these methods defined? How do I conditionally include a header file by whether or not that file exists? And then, do I need to ensure that all methods are present? And
timespecafter
won't be defined, because that is one I wrote myself to make the logic as direct and explicit as possible in the database file. I considered conditionally defining the macros, but I wasn't certain how to do that, or if I would need to include some header file to try and get the system's macros, if they exist, into the project.If you have any guidance on how you want to conditionally define this stuff, I'm happy to give it a try. I ended up just deciding that it wasn't much code to bring in, it is pretty clear what it does, and if we own that code, we can guarantee behavior.
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.
You use
have_header
inextconf.rb
which then defineHAVE_...
which you can check with a# ifdef
https://ruby-doc.org/stdlib-2.5.1/libdoc/mkmf/rdoc/MakeMakefile.html#method-i-have_header