Can you cancel a running OleDB query?

The offical for ZeosLib 7.3 Report problems, ask for help, post proposals for the new version of Zeoslib 7.3/v8
Quick Info:
-We made two new drivers: odbc(raw and unicode version) and oledb
-GUID domain/field-defined support for FB
-extended error infos of Firebird
-performance ups are still in queue
In future some more feature will arrive, so stay tuned and don't hassitate to help
Post Reply
MJFShark
Expert Boarder
Expert Boarder
Posts: 218
Joined: 04.06.2020, 13:59

Can you cancel a running OleDB query?

Post by MJFShark »

Hi all!

I've been testing the TZConnection.AbortOperation method which works great for the supported drivers. I'm also using SQL Server through the OleDB interface, and it doesn't support this method, however I notice it has a "Cancel" method on the statement objects. Is that in any way similar? I tried using it but no luck (I think it doesn't do what I thought it might.) Any info appreciated!

-Mark
User avatar
aehimself
Zeos Dev Team
Zeos Dev Team
Posts: 799
Joined: 18.11.2018, 17:37
Location: Hungary

Re: Can you cancel a running OleDB query?

Post by aehimself »

Hi Mark,

I'm glad to hear it works fine for you :) I do believe I saw those too when I implemented the basics of the .AbortOperation logic. See ZDbcConnection.pas:1071:

Code: Select all

function TZAbstractDbcConnection.AbortOperation: Integer;
begin
//  Would this work...?
//  for i := fRegisteredStatements.Count-1 downto 0 do
//   IZStatement(fRegisteredStatements[i]).Cancel;
  Raise EZUnsupportedException.Create(SUnsupportedOperation);
end;
I implemented the "normal" way (telling the server to abort) where I could, but I had no chance to test on others as I have only a MySQL and an MSSQL server at home.

You can try to uncomment those lines and see if it works, I suppose?
But, even if we skip the execution of a statement on client side, either the query will still be running or simply resources will still be locked on the server side until it finishes... so be careful.
Delphi 12.2, Zeos 8 from latest GIT snapshot
Using:
- MySQL server 8.0.18; libmysql.dll 8.0.40 x64 5.7.19 x68, libmariadb.dll 3.3.11
- Oracle server 11.2.0, 12.1.0, 19.0.0; oci.dll 21.15
- MSSQL 2012, 2019; sybdb.dll FreeTDS_3102
- SQLite 3.47
Post Reply