Firebird + IBEventAlert Patch

Code samples and contributions from users for ZeosLib's DBOs of version 6.x

Moderators: gto, cipto_kh, EgonHugeist, mdaems

Post Reply
seawolf
Zeos Dev Team *
Zeos Dev Team *
Posts: 385
Joined: 04.06.2008, 19:50
Contact:

Firebird + IBEventAlert Patch

Post by seawolf »

IBEventAlerter (please add bold text) .. when set Autoregister to false
events are not unregistered

procedure TZIBEventAlerter.SetAutoRegister(const Value: boolean);
begin
if FAutoRegister <> Value then
begin
FAutoRegister := Value;
if FAutoRegister and (not Registered) and
Assigned(FConnection) and FConnection.Connected then
RegisterEvents;
if (not FAutoRegister) and (Registered) and
Assigned(FConnection) and FConnection.Connected then
UnRegisterEvents;

end;
end;

On ZDbcInterbase6Utils affectedrows for a select statement does not works

function GetAffectedRows(PlainDriver: IZInterbasePlainDriver;
StmtHandle: TISC_STMT_HANDLE; StatementType: TZIbSqlStatementType): Integer;
var
ReqInfo: Char;
OutBuffer: array[0..255] of Char;
StatusVector: TARRAY_ISC_STATUS;
begin
Result := -1;
ReqInfo := Char(isc_info_sql_records);

if PlainDriver.isc_dsql_sql_info(@StatusVector, @StmtHandle, 1,
@ReqInfo, SizeOf(OutBuffer), OutBuffer) > 0 then
Exit;
CheckInterbase6Error(PlainDriver, StatusVector);
if OutBuffer[0] = Char(isc_info_sql_records) then
begin
case StatementType of
stUpdate: Result := PlainDriver.isc_vax_integer(@OutBuffer[6], 4);
stDelete: Result := PlainDriver.isc_vax_integer(@OutBuffer[13], 4);
stSelect: Result := PlainDriver.isc_vax_integer(@OutBuffer[20], 4);
stInsert: Result := PlainDriver.isc_vax_integer(@OutBuffer[27], 4);
else Result := -1;
end;
end;
end;

Add Connection timeout parameter

ZDbcInterbase6Utils.pas

case ParamNo of
0: Continue;
isc_dpb_set_db_SQL_dialect:
Dialect := StrToIntDef(ParamValue, 0);
isc_dpb_user_name, isc_dpb_password, isc_dpb_password_enc,
isc_dpb_sys_user_name, isc_dpb_license, isc_dpb_encrypt_key,
isc_dpb_lc_messages, isc_dpb_lc_ctype, isc_dpb_sql_role_name, isc_dpb_connect_timeout:

ZdbcInterbsae6.pas

Append at the end of "constructor TZInterbase6Connection.Create"

ConnectTimeout := StrToIntDef(Info.Values['timeout'], -1);
if ConnectTimeout >= 0 then
self.Info.Values['isc_dpb_connect_timeout'] := IntToStr(ConnectTimeout);

(declaring ConnectTimeout : integer; at the beginning of that function)
User avatar
mdaems
Zeos Project Manager
Zeos Project Manager
Posts: 2766
Joined: 20.09.2005, 15:28
Location: Brussels, Belgium
Contact:

Post by mdaems »

seawolf,

I'm not convinced you're right in the first issue. Setting autoregister to false doesn't mean you want to unregister what's registered already. To do that you should set autoregister to false AND call unregisterevents yourself. It may be usefull to switch autoregistration off when you want to adjust the events list by doing multiple edits to the list that you want to be effective at once once you're sure the edits are all done. So I won't do this change right now. What do other people think about this?

Concerning the second patch :
Could you tell us in what circumstances this gives bad results? Normally AffectedRows should not be used for select queries. There RecordCount returns the number of rows found. So I don't consider this as a bug until you can prove otherwise. I added your change to testing branch anyhow, as it won't hurt, as far as I know. My first impression however is that a backport to zeoslib 6.6 is not necessary.

Last patch : accepted as a new feature for 7.0

SVN Rev 447.

Mark
Image
Post Reply