Proposed cancel changes. #145
Open
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.
Splits
pg_db_cancelinto a sychronous cancel operation callledpg_db_canceland a function which just sends a cancel request to the server without waiting for the result calledpg_db_send_cancel. Fixes the cancel result handling code inpg_db_cancelby invokingpg_db_resultto wait for the result of the possibly cancelled query instead of partially duplicating the result handling code inpg_db_cancelitself.Introduces a new internal function called
do_send_cancelwhich contains just the cancel request sending logic and calls that from all places in the original code which used to duplicate this functionality.Changes
pg_db_resultsuch that it no longer treats cancelled queries as fatal errors but returns zero and a SQLSTATE of 57014 instead.Modifies t/08async.t to enable AutoCommit so that cancelled queries no longer cause transaction aborts which would need to be dealt with by rollbacks. Removes a now redundant
$dbh->commit(). Changeshandle_old_asynccancel path to only issue a rollback if actually in a transaction to avoid warnings about issueing a rollback outside of a transaction.Unrelated fix: Uses the correct TRACE macro (
TRACE_PQCANCEL) when about to callPQcancelinstead of theTRACE_PQGETCANCELwhich was used in this place instead.This passes the test suite plus the two tests I added for
pg_db_send_cancel.