Skip to content

Conversation

@rweikusat
Copy link

Splits pg_db_cancel into a sychronous cancel operation callled pg_db_cancel and a function which just sends a cancel request to the server without waiting for the result called pg_db_send_cancel. Fixes the cancel result handling code in pg_db_cancel by invoking pg_db_result to wait for the result of the possibly cancelled query instead of partially duplicating the result handling code in pg_db_cancel itself.

Introduces a new internal function called do_send_cancel which 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_result such 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(). Changes handle_old_async cancel 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 call PQcancel instead of the TRACE_PQGETCANCEL which was used in this place instead.

This passes the test suite plus the two tests I added for pg_db_send_cancel.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant