You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have a UDF in FB2.1 used in many clients, without problems.
I'm testing the FB2.5 and with the same UDF and 4 from 6 functions from this UDF crash the connection.
I don´t see nothing new in documentation only the FREE_IT, I test but still the same problem.
SQL:
select IntToDate(45000) from rdb$database --> this function Crash connection
select DateToInt(current_timestamp) from rdb$database --> OK! return 40939
DELPHI part of code
unit myfuncs;
uses
SysUtils, DateUtils, ibase, ib_externals, fb_descriptors, math;
function DateToInt(ib_date: PISC_QUAD): Integer; cdecl; export;
function IntToDate(val1: PParamDsc): PISC_QUAD; cdecl; export;
...
procedure SetaConfiguracoesRegionais;
implementation
function DateToInt(ib_date: PISC_QUAD): Integer; cdecl; export;
var
Data: TDateTime;
begin
Data := isc_decode_TDateTime(ib_date);
if (Data < EncodeDate(1899,12,30)) then
begin
result := 0;
Exit;
end;
result := DaysBetween(Data,EncodeDate(1899,12,30));
end;
function IntToDate(val1: PParamDsc): PISC_QUAD; cdecl; export;
var
Data: TDateTime;
v1: Int64;
begin
if (val1 = nil) or ((val1^.dsc_flags and DSC_null) <> 0) then
begin
result := nil;
Exit;
end;
get_int_type(val1, v1);
Data := EncodeDate(1899,12,30) + v1;
isc_encode_TDateTime(Data,result);
end;
...
//code from IBO
function isc_decode_TDateTime(const Src: PISC_QUAD): TDateTime;
begin
Result := Src^.gds_quad_high - 15018;
try
Result := Result + EncodeTime((Src^.gds_quad_low div (36000000)),
(Src^.gds_quad_low div (600000)) mod 60,
(Src^.gds_quad_low div (10000)) mod 60,
(Src^.gds_quad_low mod (10000)) div 10);
except
Result := Result + 0;
end;
end;
procedure isc_encode_TDateTime(const Src: TDateTime; const Dst: PISC_QUAD);
var
Hour, Min, Sec, MSec: word;
begin
DecodeTime(Src, Hour, Min, Sec, MSec);
with Dst^ do
begin
gds_quad_high := Trunc(Src) + 15018;
gds_quad_low := Hour * 10000 * 60 * 60 +
Min * 10000 * 60 +
Sec * 10000 +
MSec * 10;
end;
end;
The text was updated successfully, but these errors were encountered:
Submitted by: André Müller Pereira (andremp)
Attachments:
accessUDF.dll
I have a UDF in FB2.1 used in many clients, without problems.
I'm testing the FB2.5 and with the same UDF and 4 from 6 functions from this UDF crash the connection.
I don´t see nothing new in documentation only the FREE_IT, I test but still the same problem.
Have some changes that I don't read ?
example:
DECLARE EXTERNAL FUNCTION FormatDate
TIMESTAMP,
CSTRING(80)
RETURNS CSTRING(80)
ENTRY_POINT 'FormatDate' MODULE_NAME 'accessUDF';
SQL:
select IntToDate(45000) from rdb$database --> this function Crash connection
select DateToInt(current_timestamp) from rdb$database --> OK! return 40939
DELPHI part of code
unit myfuncs;
uses
SysUtils, DateUtils, ibase, ib_externals, fb_descriptors, math;
function DateToInt(ib_date: PISC_QUAD): Integer; cdecl; export;
function IntToDate(val1: PParamDsc): PISC_QUAD; cdecl; export;
...
procedure SetaConfiguracoesRegionais;
implementation
function DateToInt(ib_date: PISC_QUAD): Integer; cdecl; export;
var
Data: TDateTime;
begin
Data := isc_decode_TDateTime(ib_date);
if (Data < EncodeDate(1899,12,30)) then
begin
result := 0;
Exit;
end;
result := DaysBetween(Data,EncodeDate(1899,12,30));
end;
function IntToDate(val1: PParamDsc): PISC_QUAD; cdecl; export;
var
Data: TDateTime;
v1: Int64;
begin
if (val1 = nil) or ((val1^.dsc_flags and DSC_null) <> 0) then
begin
result := nil;
Exit;
end;
get_int_type(val1, v1);
Data := EncodeDate(1899,12,30) + v1;
isc_encode_TDateTime(Data,result);
end;
...
//code from IBO
function isc_decode_TDateTime(const Src: PISC_QUAD): TDateTime;
begin
Result := Src^.gds_quad_high - 15018;
try
Result := Result + EncodeTime((Src^.gds_quad_low div (36000000)),
(Src^.gds_quad_low div (600000)) mod 60,
(Src^.gds_quad_low div (10000)) mod 60,
(Src^.gds_quad_low mod (10000)) div 10);
except
Result := Result + 0;
end;
end;
procedure isc_encode_TDateTime(const Src: TDateTime; const Dst: PISC_QUAD);
var
Hour, Min, Sec, MSec: word;
begin
DecodeTime(Src, Hour, Min, Sec, MSec);
with Dst^ do
begin
gds_quad_high := Trunc(Src) + 15018;
gds_quad_low := Hour * 10000 * 60 * 60 +
Min * 10000 * 60 +
Sec * 10000 +
MSec * 10;
end;
end;
The text was updated successfully, but these errors were encountered: