AbortOperation issue
AbortOperation issue
There is a mismatch between the return values from AbortOperation (I refer to the last version I'm using but that seems to be going on for some time https://github.com/frones/ZeosLib/tree/ ... ffe888/src)
TZSQLiteConnection.AbortOperation always returns 1
TZPostgreSQLConnection.AbortOperation set the default to 1 but on success returns 0
TZOracleConnection.AbortOperation only returns 0 (raises exception on fail)
TZFirebirdConnection.AbortOperation while I cannot test it, seems to return 1 on success and 0 and failure
What should be the correct behavior in that case, with regard to the other parts of zeos?
TZSQLiteConnection.AbortOperation always returns 1
TZPostgreSQLConnection.AbortOperation set the default to 1 but on success returns 0
TZOracleConnection.AbortOperation only returns 0 (raises exception on fail)
TZFirebirdConnection.AbortOperation while I cannot test it, seems to return 1 on success and 0 and failure
What should be the correct behavior in that case, with regard to the other parts of zeos?
-
- Platinum Boarder
- Posts: 1956
- Joined: 17.01.2011, 14:17
Re: AbortOperation issue
Hello stoffman,
even though I didn't look at the code, I would expect that the return value of AbortOperation is irrelevant and that an Exception is raised if AbortOperation doesn't work.
A note on the branch of Zeos that you refer to: Please use https://github.com/marsupilami79/zeoslib. It is more or less our official copy and is kept up to date automatically.
Best regards,
Jan
even though I didn't look at the code, I would expect that the return value of AbortOperation is irrelevant and that an Exception is raised if AbortOperation doesn't work.
A note on the branch of Zeos that you refer to: Please use https://github.com/marsupilami79/zeoslib. It is more or less our official copy and is kept up to date automatically.
Best regards,
Jan
Re: AbortOperation issue
It feels like this was copied form JDBC design where you have checked exceptions, so the user knows to try and catch AbortOperation. But in pascal it makes less sense
At least in that regard the sqlite driver behave differently has it doesn't raise any exception.
Also in TZAbstractConnection:
which means that it will always return false for sqlite.
At least in that regard the sqlite driver behave differently has it doesn't raise any exception.
Also in TZAbstractConnection:
Code: Select all
function TZAbstractConnection.AbortOperation: Boolean;
begin
Result := FConnection.AbortOperation = 0;
end;
Re: AbortOperation issue
Was a long time ago but I think I copied the behavior from Ping... which SHOULD mean 0 on success, 1 on error. Later on we introduced EZNotSupportedException, we also could implement that; makes sense if the driver doesn't (yet) support aborting.
I'll take a closer look tomorrow.
I'll take a closer look tomorrow.
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
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
Re: AbortOperation issue
As it turns out yes, return values were not used correctly in every driver. I issued a pull request on GitHub which attempts to fix this.
However, as I analyzed the code Firebird is completely wrong. I put some notes there explaining why it needs to be reworked... Unfortunately I don't have Firebird available to be able to check and test it.
However, as I analyzed the code Firebird is completely wrong. I put some notes there explaining why it needs to be reworked... Unfortunately I don't have Firebird available to be able to check and test it.
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
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
-
- Platinum Boarder
- Posts: 1956
- Joined: 17.01.2011, 14:17
Re: AbortOperation issue
I applied the changes to Zeos trunk and Zeos 8.0-patches
Re: AbortOperation issue
I would also like to recommend a change of code in TZDbcPooledConnection.AbortOperation , The way it works now is that if it doesn't have a connection it obtain one only to abort it immediately. This is a waste. It should first check whatever the connection IsClosed and if not try to abort it. if it is close it should return success.
-
- Platinum Boarder
- Posts: 1956
- Joined: 17.01.2011, 14:17
Re: AbortOperation issue
I use Firebird on a daily basis. What tests should I do? Should we try to integrate tests into the test suite?
Re: AbortOperation issue
Jan,
This is the comment I put in .AbortOperation for Firebird:
Code: Select all
// This is a mess and probably doesn't work as intended. cIStatus_RESULT_OK is 0, which means it doesn't matter what
// getState returns, anything AND 0 will be 0. Therefore, 0 <> 0 will always return FALSE and Ord(False) is always 0.
// Result is always 0, so FStatus.init will never be called...
Result := Ord((Fstatus.getState and cIStatus_RESULT_OK) <> 0);
if Result <> 0 then
FStatus.init;
What I'd do is to try to call .AbortOperation on Firebird and check what this GetStatus returns. Maybe we can start from there to try to untangle the correct way...
Shortly after implementing .AbortOperation I remember writing some SLEEP queries for MSSQL, MySQL and maybe for Oracle so we can check if aborting is actually successful. Those could be turned into tests for the suite.
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
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
Re: AbortOperation issue
Good catch! Ripe pull request is ready for picking!stoffman wrote: ↑11.09.2024, 08:31I would also like to recommend a change of code in TZDbcPooledConnection.AbortOperation , The way it works now is that if it doesn't have a connection it obtain one only to abort it immediately. This is a waste. It should first check whatever the connection IsClosed and if not try to abort it. if it is close it should return success.
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
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