Page 1 of 1

MSSQL FreeTDS OR Native Db Lib

Posted: 14.09.2020, 10:57
by nitrotek
Hi
I have the problem with working mssql 2008. I can't control query timeout using freetds or native dblib.
I check the code and found problem. Not defined function dbsettime in ZPlainDbLibDriver.pas.

Why call to dbsettime redirecting to dbsetmaxprocs?

Code: Select all

function TZFreeTDSBasePlainDriver.dbsetmaxprocs(
  MaxProcs: SmallInt): RETCODE;
begin
  Result := FreeTDSAPI.dbsetmaxprocs(MaxProcs);
end;

function TZFreeTDSBasePlainDriver.dbSetTime(queryTime: Integer): RETCODE;
begin
  Result := FreeTDSAPI.dbsetmaxprocs(queryTime);
end;
Both libraries ntwdblib.dll and libsybdb-5.dll has exports dbsettime function. But in zeos this method even not implemented in block of load dynamic functions. After implement this function i can to change query timeout value. It works.

Code: Select all

Add to ZPlainDbLibConstants.pas:
type
   .........
   TFreeTDSdbsettime       =  function(QueryTime: DBINT): RETCODE; cdecl;
   ...........
   TFreeTDSAPI = record
   .......
      dbsettime:      TFreeTDSdbsettime;   	
   end;
   
Add to ZPlainDbLibDriver.pas:
procedure TZFreeTDSBasePlainDriver.LoadApi;
begin
   .................
   @FreeTDSAPI.dbsettime       := GetAddress('dbsettime');
   ................
end;

Set:
function TZFreeTDSBasePlainDriver.dbSetTime(queryTime: Integer): RETCODE;
begin
  Result := FreeTDSAPI.dbsetmaxprocs(queryTime);
end;

To:
function TZFreeTDSBasePlainDriver.dbSetTime(queryTime: Integer): RETCODE;
begin
  Result := FreeTDSAPI.dbsettime(queryTime);
end;

use as:
(AConnection.DbcConnection.GetIZPlainDriver as IZFreeTDSPlainDriver).dbSetTime(<You query timeout>);
But I have doubts. Is this just a mistake or made for some reason?

Re: MSSQL FreeTDS OR Native Db Lib

Posted: 14.09.2020, 14:59
by marsupilami
Please assume, that this is a mistake on Zeos side. I created a bug report on SourceForge nonetheless: https://sourceforge.net/p/zeoslib/tickets/445/