trino-python-client icon indicating copy to clipboard operation
trino-python-client copied to clipboard

Improve cursor close and connection close behaviour

Open hashhar opened this issue 1 year ago • 1 comments

From https://github.com/trinodb/trino-python-client/pull/405#issuecomment-1705226919

In my head the logic should be:

  • On cursor.close()
    • Cancel any already executing queries if they exist
    • Perform implicit ROLLBACK if within a transaction
    • Set some boolean so that calling any method of the cursor leads to Error

We don't do steps 2 and 3 here (both required by DB-API).

  • On cursor.cancel() - this is not a DB-API specified method so the behaviour is up to us to specify
    • Cancel any already executing queries
      • If query already finished, return False
      • If query is running and was cancelled successfully, return True
      • If no query was executed at all (how to differentiate between this and already finished? - presence of query on the cursor?) then raise Exception

hashhar avatar Feb 05 '25 10:02 hashhar

We can focus on implementing "Set some boolean so that calling any method of the cursor leads to Error" for cursor.close() as that's the main thing we are missing. Transactions are not supported properly anyway so whether we ROLLBACK or not doesn't seem important for now

hashhar avatar Feb 27 '25 09:02 hashhar