-
Notifications
You must be signed in to change notification settings - Fork 50
Add support for query timeouts #247
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
Conversation
@@ -20,6 +21,8 @@ public class DuckDBDriver implements java.sql.Driver { | |||
static final String DUCKDB_URL_PREFIX = "jdbc:duckdb:"; | |||
static final String MEMORY_DB = ":memory:"; | |||
|
|||
static final ScheduledThreadPoolExecutor scheduler = new ScheduledThreadPoolExecutor(1); |
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.
It would be helpful when the thread name has a meaningful name. We could achieve this by using a ThreadFactory
as second argument to set the name a new thread is created.
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.
Thanks for the review! Good idea, updated the PR to add this.
cbfa8ff
to
fdd9a47
Compare
This change implements `Statement#setQueryTimeout()` method. It is implemented by scheduling a background task and calling `Statement#cancel()` when timeout expires. Timeouted statement has the same behaviour as it would be if cancelled manually - `SQLException` is thrown and the statement is closed. Timeout is applied for all `execute*` calls. For `executeBatch()` it is applied separately for every single query in a batch. Testing: new test added. Fixes: duckdb#212
This change restores the contents of duckdb#250 that were inadvertently removed in duckdb#247.
This change restores the contents of duckdb#250 that were inadvertently removed in duckdb#247.
This is a backport of the PR duckdb#247 to `v1.3-ossivalis` stable branch. This change implements `Statement#setQueryTimeout()` method. It is implemented by scheduling a background task and calling `Statement#cancel()` when timeout expires. Timeouted statement has the same behaviour as it would be if cancelled manually - `SQLException` is thrown and the statement is closed. Timeout is applied for all `execute*` calls. For `executeBatch()` it is applied separately for every single query in a batch. Testing: new test added. Fixes: duckdb#212
This is a backport of the PR #247 to `v1.3-ossivalis` stable branch. This change implements `Statement#setQueryTimeout()` method. It is implemented by scheduling a background task and calling `Statement#cancel()` when timeout expires. Timeouted statement has the same behaviour as it would be if cancelled manually - `SQLException` is thrown and the statement is closed. Timeout is applied for all `execute*` calls. For `executeBatch()` it is applied separately for every single query in a batch. Testing: new test added. Fixes: #212
This change implements
Statement#setQueryTimeout()
method. It is implemented by scheduling a background task and callingStatement#cancel()
when timeout expires.Timeouted statement has the same behaviour as it would be if cancelled manually -
SQLException
is thrown and the statement is closed.Timeout is applied for all
execute*
calls. ForexecuteBatch()
it is applied separately for every single query in a batch.Testing: new test added.
Fixes: #212