74 |
|
uses |
75 |
|
Classes, SysUtils, FBClientAPI, IBHeader, IBExternals, IB; |
76 |
|
|
77 |
– |
const |
78 |
– |
FBClientInterfaceVersion = '2.5'; |
79 |
– |
|
77 |
|
type |
78 |
|
|
79 |
|
{ TFB25Status } |
111 |
|
BLOB_put: TBLOB_put; |
112 |
|
isc_wait_for_event: Tisc_wait_for_event; |
113 |
|
isc_vax_integer: Tisc_vax_integer; |
117 |
– |
isc_portable_integer: Tisc_portable_integer; |
114 |
|
isc_blob_info: Tisc_blob_info; |
115 |
|
isc_blob_lookup_desc: Tisc_blob_lookup_desc; |
116 |
|
isc_open_blob2: Tisc_open_blob2; |
162 |
|
isc_array_put_slice: Tisc_array_put_slice; |
163 |
|
isc_prepare_transaction: Tisc_prepare_transaction; |
164 |
|
isc_version: Tisc_Version; |
165 |
+ |
isc_interprete: Tisc_interprete; |
166 |
|
|
167 |
|
public |
168 |
|
{Helper Functions} |
172 |
– |
function DecodeInteger(bufptr: PByte; len: short): integer; override; |
169 |
|
procedure SQLEncodeDate(aDate: TDateTime; bufptr: PByte); override; |
170 |
|
function SQLDecodeDate(bufptr: PByte): TDateTime; override; |
171 |
|
procedure SQLEncodeTime(aTime: TDateTime; bufptr: PByte); override; |
172 |
|
function SQLDecodeTime(bufptr: PByte): TDateTime; override; |
173 |
|
procedure SQLEncodeDateTime(aDateTime: TDateTime; bufptr: PByte); override; |
174 |
|
function SQLDecodeDateTime(bufptr: PByte): TDateTime; override; |
175 |
< |
|
175 |
> |
function FormatStatus(Status: TFBStatus): AnsiString; override; |
176 |
|
public |
177 |
|
{IFirebirdAPI} |
178 |
|
|
199 |
|
function GetStatus: IStatus; override; |
200 |
|
function HasRollbackRetaining: boolean; |
201 |
|
function IsEmbeddedServer: boolean; override; |
202 |
< |
function GetImplementationVersion: AnsiString; |
202 |
> |
function GetClientMajor: integer; override; |
203 |
> |
function GetClientMinor: integer; override; |
204 |
|
|
205 |
|
{Firebird 3 API} |
206 |
|
function HasMasterIntf: boolean; |
213 |
|
uses FBMessages, |
214 |
|
{$IFDEF WINDOWS}Windows, {$ENDIF} |
215 |
|
{$IFDEF FPC} Dynlibs, {$ENDIF} |
216 |
< |
FB25Attachment, FB25Transaction, FB25Services, FBParamBlock, |
217 |
< |
IBUtils; |
216 |
> |
FB25Attachment, FB25Transaction, FB25Services, |
217 |
> |
IBUtils, FBAttachment, FBTransaction, FBServices; |
218 |
|
|
219 |
|
{ Stubs for 6.0 only functions } |
220 |
|
function isc_rollback_retaining_stub(status_vector : PISC_STATUS; |
342 |
|
BLOB_put := GetProcAddr('BLOB_put'); {do not localize} |
343 |
|
isc_wait_for_event := GetProcAddr('isc_wait_for_event'); {do not localize} |
344 |
|
isc_vax_integer := GetProcAddr('isc_vax_integer'); {do not localize} |
348 |
– |
isc_portable_integer := GetProcAddr('isc_portable_integer'); {do not localize} |
345 |
|
isc_blob_info := GetProcAddr('isc_blob_info'); {do not localize} |
346 |
|
isc_blob_lookup_desc := GetProcAddr('isc_blob_lookup_desc'); {do not localize} |
347 |
|
isc_open_blob2 := GetProcAddr('isc_open_blob2'); {do not localize} |
382 |
|
isc_array_put_slice := GetProcAddr('isc_array_put_slice'); {do not localize} |
383 |
|
isc_prepare_transaction := GetProcAddr('isc_prepare_transaction'); {do not localize} |
384 |
|
isc_version := GetProcAddr('isc_version'); {do not localize} |
385 |
+ |
isc_interprete := GetProcAddr('isc_interprete'); {do not localize} |
386 |
|
|
387 |
|
FIBServiceAPIPresent := true; |
388 |
|
isc_rollback_retaining := GetProcAddress(FFBLibrary.IBLibrary, 'isc_rollback_retaining'); {do not localize} |
535 |
|
{$ENDIF} |
536 |
|
end; |
537 |
|
|
538 |
< |
function TFB25ClientAPI.HasMasterIntf: boolean; |
538 |
> |
function TFB25ClientAPI.GetClientMajor: integer; |
539 |
|
begin |
540 |
< |
Result := false; |
540 |
> |
Result := 2; |
541 |
|
end; |
542 |
|
|
543 |
< |
function TFB25ClientAPI.GetIMaster: TObject; |
543 |
> |
function TFB25ClientAPI.GetClientMinor: integer; |
544 |
|
begin |
545 |
< |
Result := nil; |
545 |
> |
Result := 5; |
546 |
|
end; |
547 |
|
|
548 |
< |
function TFB25ClientAPI.GetImplementationVersion: AnsiString; |
548 |
> |
function TFB25ClientAPI.HasMasterIntf: boolean; |
549 |
|
begin |
550 |
< |
Result := FBClientInterfaceVersion; |
550 |
> |
Result := false; |
551 |
|
end; |
552 |
|
|
553 |
< |
function TFB25ClientAPI.DecodeInteger(bufptr: PByte; len: short): integer; |
553 |
> |
function TFB25ClientAPI.GetIMaster: TObject; |
554 |
|
begin |
555 |
< |
Result := isc_portable_integer(bufptr,len); |
555 |
> |
Result := nil; |
556 |
|
end; |
557 |
|
|
558 |
|
procedure TFB25ClientAPI.SQLEncodeDate(aDate: TDateTime; bufptr: PByte); |
590 |
|
procedure TFB25ClientAPI.SQLEncodeTime(aTime: TDateTime; bufptr: PByte); |
591 |
|
var |
592 |
|
tm_date: TCTimeStructure; |
593 |
< |
Hr, Mt, S, Ms: Word; |
593 |
> |
Hr, Mt, S: Word; |
594 |
> |
DMs: cardinal; {DMs = decimilliseconds} |
595 |
|
begin |
596 |
< |
DecodeTime(aTime, Hr, Mt, S, Ms); |
596 |
> |
FBDecodeTime(aTime, Hr, Mt, S, DMs); |
597 |
|
with tm_date do begin |
598 |
|
tm_sec := S; |
599 |
|
tm_min := Mt; |
603 |
|
tm_year := 0; |
604 |
|
end; |
605 |
|
isc_encode_sql_time(@tm_date, PISC_TIME(bufptr)); |
606 |
< |
if Ms > 0 then |
607 |
< |
Inc(PISC_TIME(bufptr)^,Ms*10); |
606 |
> |
if DMs > 0 then |
607 |
> |
Inc(PISC_TIME(bufptr)^,DMs); |
608 |
|
end; |
609 |
|
|
610 |
|
function TFB25ClientAPI.SQLDecodeTime(bufptr: PByte): TDateTime; |
611 |
|
var |
612 |
|
tm_date: TCTimeStructure; |
613 |
< |
msecs: Word; |
613 |
> |
DMs: cardinal; {DMs = decimilliseconds} |
614 |
|
begin |
615 |
|
isc_decode_sql_time(PISC_TIME(bufptr), @tm_date); |
616 |
|
try |
617 |
< |
msecs := (PISC_TIME(bufptr)^ mod 10000) div 10; |
618 |
< |
result := EncodeTime(Word(tm_date.tm_hour), Word(tm_date.tm_min), |
619 |
< |
Word(tm_date.tm_sec), msecs) |
617 |
> |
DMs := PISC_TIME(bufptr)^ mod 10000; |
618 |
> |
result := FBEncodeTime(Word(tm_date.tm_hour), Word(tm_date.tm_min), |
619 |
> |
Word(tm_date.tm_sec), DMs) |
620 |
|
except |
621 |
|
on E: EConvertError do begin |
622 |
|
IBError(ibxeInvalidDataConversion, [nil]); |
628 |
|
var |
629 |
|
tm_date: TCTimeStructure; |
630 |
|
Yr, Mn, Dy, Hr, Mt, S, Ms: Word; |
631 |
+ |
DMs: cardinal; |
632 |
|
begin |
633 |
|
DecodeDate(aDateTime, Yr, Mn, Dy); |
634 |
< |
DecodeTime(aDateTime, Hr, Mt, S, Ms); |
634 |
> |
FBDecodeTime(aDateTime, Hr, Mt, S, DMs); |
635 |
|
with tm_date do begin |
636 |
|
tm_sec := S; |
637 |
|
tm_min := Mt; |
641 |
|
tm_year := Yr - 1900; |
642 |
|
end; |
643 |
|
isc_encode_date(@tm_date, PISC_QUAD(bufptr)); |
644 |
< |
if Ms > 0 then |
645 |
< |
Inc(PISC_TIMESTAMP(bufptr)^.timestamp_time,Ms*10); |
644 |
> |
if DMs > 0 then |
645 |
> |
Inc(PISC_TIMESTAMP(bufptr)^.timestamp_time,DMs); |
646 |
|
end; |
647 |
|
|
648 |
|
function TFB25ClientAPI.SQLDecodeDateTime(bufptr: PByte): TDateTime; |
649 |
|
var |
650 |
|
tm_date: TCTimeStructure; |
651 |
< |
msecs: Word; |
651 |
> |
Dmsecs: Word; |
652 |
|
begin |
653 |
|
isc_decode_date(PISC_QUAD(bufptr), @tm_date); |
654 |
|
try |
655 |
|
result := EncodeDate(Word(tm_date.tm_year + 1900), Word(tm_date.tm_mon + 1), |
656 |
|
Word(tm_date.tm_mday)); |
657 |
< |
msecs := (PISC_TIMESTAMP(bufptr)^.timestamp_time mod 10000) div 10; |
657 |
> |
Dmsecs := PISC_TIMESTAMP(bufptr)^.timestamp_time mod 10000; |
658 |
|
if result >= 0 then |
659 |
< |
result := result + EncodeTime(Word(tm_date.tm_hour), Word(tm_date.tm_min), |
660 |
< |
Word(tm_date.tm_sec), msecs) |
659 |
> |
result := result + FBEncodeTime(Word(tm_date.tm_hour), Word(tm_date.tm_min), |
660 |
> |
Word(tm_date.tm_sec), Dmsecs) |
661 |
|
else |
662 |
< |
result := result - EncodeTime(Word(tm_date.tm_hour), Word(tm_date.tm_min), |
663 |
< |
Word(tm_date.tm_sec), msecs) |
662 |
> |
result := result - FBEncodeTime(Word(tm_date.tm_hour), Word(tm_date.tm_min), |
663 |
> |
Word(tm_date.tm_sec), Dmsecs) |
664 |
|
except |
665 |
|
on E: EConvertError do begin |
666 |
|
IBError(ibxeInvalidDataConversion, [nil]); |
668 |
|
end; |
669 |
|
end; |
670 |
|
|
671 |
+ |
function TFB25ClientAPI.FormatStatus(Status: TFBStatus): AnsiString; |
672 |
+ |
var psb: PStatusVector; |
673 |
+ |
local_buffer: array[0..IBHugeLocalBufferLength - 1] of AnsiChar; |
674 |
+ |
begin |
675 |
+ |
psb := Status.StatusVector; |
676 |
+ |
Result := ''; |
677 |
+ |
while isc_interprete(@local_buffer,@psb) > 0 do |
678 |
+ |
begin |
679 |
+ |
if (Result <> '') and (Result[Length(Result)] <> LF) then |
680 |
+ |
Result := Result + LineEnding + '-'; |
681 |
+ |
Result := Result + strpas(local_buffer); |
682 |
+ |
end; |
683 |
+ |
end; |
684 |
+ |
|
685 |
|
end. |
686 |
|
|
687 |
|
|