how is the way for cancel query?
See original GitHub issueCan I cancel a query inside query.on(‘row’…?
I want to do something like:
query.on('row',function(row, result){
if(row.field1=='ok'){
result.addRow(row);
}else{
result.cancel(row, 'bla bla bla');
}
});
The need is to not continue fetching rows if I detect an error condition.
Issue Analytics
- State:
- Created 8 years ago
- Reactions:2
- Comments:26 (9 by maintainers)
Top Results From Across the Web
CANCEL QUERY | CockroachDB Docs
The CANCEL QUERY statement cancels a running SQL query. Considerations. Schema changes are treated differently than other SQL queries.
Read more >Options - Cancel Queries
There are two ways to cancel the query during the first phase: ODBC Driver. This option is available if your ODBC Driver supports...
Read more >Canceling Statements - Snowflake Documentation
The recommended way to cancel a statement is to use the interface of the application in which the query is running (e.g. the...
Read more >How to cancel a query and return a subset of records - Ask TOM
How to cancel a query and return a subset of records I have a requirement like this:One of the database table can have...
Read more >How to CANCEL a query running in another session?
Before we go on, here's how query cancellation (pressing CTRL+C in sqlplus for example) works in Oracle:
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
You should be able to cancel queries using
pg_cancel_backend()
. I think the pattern looks like this:This is VERY expensive, especially in a scenario where resources are limited.
A better approach would be to have a reserved pool for cancelling connections:
Whether you want the user to instantiate the admin pool, or allow them to specify the number of reserved connections, I think either is fine. I expect the latter would be quite a significant refactor, to have Pool manage two logical pools.