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 |
> |
function HasScollableCursors: boolean; |
205 |
|
|
206 |
|
{Firebird 3 API} |
207 |
|
function HasMasterIntf: boolean; |
214 |
|
uses FBMessages, |
215 |
|
{$IFDEF WINDOWS}Windows, {$ENDIF} |
216 |
|
{$IFDEF FPC} Dynlibs, {$ENDIF} |
217 |
< |
FB25Attachment, FB25Transaction, FB25Services, FBParamBlock, |
218 |
< |
IBUtils; |
217 |
> |
FB25Attachment, FB25Transaction, FB25Services, |
218 |
> |
IBUtils, FBAttachment, FBTransaction, FBServices; |
219 |
|
|
220 |
|
{ Stubs for 6.0 only functions } |
221 |
|
function isc_rollback_retaining_stub(status_vector : PISC_STATUS; |
343 |
|
BLOB_put := GetProcAddr('BLOB_put'); {do not localize} |
344 |
|
isc_wait_for_event := GetProcAddr('isc_wait_for_event'); {do not localize} |
345 |
|
isc_vax_integer := GetProcAddr('isc_vax_integer'); {do not localize} |
348 |
– |
isc_portable_integer := GetProcAddr('isc_portable_integer'); {do not localize} |
346 |
|
isc_blob_info := GetProcAddr('isc_blob_info'); {do not localize} |
347 |
|
isc_blob_lookup_desc := GetProcAddr('isc_blob_lookup_desc'); {do not localize} |
348 |
|
isc_open_blob2 := GetProcAddr('isc_open_blob2'); {do not localize} |
383 |
|
isc_array_put_slice := GetProcAddr('isc_array_put_slice'); {do not localize} |
384 |
|
isc_prepare_transaction := GetProcAddr('isc_prepare_transaction'); {do not localize} |
385 |
|
isc_version := GetProcAddr('isc_version'); {do not localize} |
386 |
+ |
isc_interprete := GetProcAddr('isc_interprete'); {do not localize} |
387 |
|
|
388 |
|
FIBServiceAPIPresent := true; |
389 |
|
isc_rollback_retaining := GetProcAddress(FFBLibrary.IBLibrary, 'isc_rollback_retaining'); {do not localize} |
536 |
|
{$ENDIF} |
537 |
|
end; |
538 |
|
|
539 |
< |
function TFB25ClientAPI.HasMasterIntf: boolean; |
539 |
> |
function TFB25ClientAPI.GetClientMajor: integer; |
540 |
|
begin |
541 |
< |
Result := false; |
541 |
> |
Result := 2; |
542 |
|
end; |
543 |
|
|
544 |
< |
function TFB25ClientAPI.GetIMaster: TObject; |
544 |
> |
function TFB25ClientAPI.GetClientMinor: integer; |
545 |
|
begin |
546 |
< |
Result := nil; |
546 |
> |
Result := 5; |
547 |
> |
end; |
548 |
> |
|
549 |
> |
function TFB25ClientAPI.HasScollableCursors: boolean; |
550 |
> |
begin |
551 |
> |
Result := false; |
552 |
|
end; |
553 |
|
|
554 |
< |
function TFB25ClientAPI.GetImplementationVersion: AnsiString; |
554 |
> |
function TFB25ClientAPI.HasMasterIntf: boolean; |
555 |
|
begin |
556 |
< |
Result := FBClientInterfaceVersion; |
556 |
> |
Result := false; |
557 |
|
end; |
558 |
|
|
559 |
< |
function TFB25ClientAPI.DecodeInteger(bufptr: PByte; len: short): integer; |
559 |
> |
function TFB25ClientAPI.GetIMaster: TObject; |
560 |
|
begin |
561 |
< |
Result := isc_portable_integer(bufptr,len); |
561 |
> |
Result := nil; |
562 |
|
end; |
563 |
|
|
564 |
|
procedure TFB25ClientAPI.SQLEncodeDate(aDate: TDateTime; bufptr: PByte); |
596 |
|
procedure TFB25ClientAPI.SQLEncodeTime(aTime: TDateTime; bufptr: PByte); |
597 |
|
var |
598 |
|
tm_date: TCTimeStructure; |
599 |
< |
Hr, Mt, S, Ms: Word; |
599 |
> |
Hr, Mt, S: Word; |
600 |
> |
DMs: cardinal; {DMs = decimilliseconds} |
601 |
|
begin |
602 |
< |
DecodeTime(aTime, Hr, Mt, S, Ms); |
602 |
> |
FBDecodeTime(aTime, Hr, Mt, S, DMs); |
603 |
|
with tm_date do begin |
604 |
|
tm_sec := S; |
605 |
|
tm_min := Mt; |
609 |
|
tm_year := 0; |
610 |
|
end; |
611 |
|
isc_encode_sql_time(@tm_date, PISC_TIME(bufptr)); |
612 |
< |
if Ms > 0 then |
613 |
< |
Inc(PISC_TIME(bufptr)^,Ms*10); |
612 |
> |
if DMs > 0 then |
613 |
> |
Inc(PISC_TIME(bufptr)^,DMs); |
614 |
|
end; |
615 |
|
|
616 |
|
function TFB25ClientAPI.SQLDecodeTime(bufptr: PByte): TDateTime; |
617 |
|
var |
618 |
|
tm_date: TCTimeStructure; |
619 |
< |
msecs: Word; |
619 |
> |
DMs: cardinal; {DMs = decimilliseconds} |
620 |
|
begin |
621 |
|
isc_decode_sql_time(PISC_TIME(bufptr), @tm_date); |
622 |
|
try |
623 |
< |
msecs := (PISC_TIME(bufptr)^ mod 10000) div 10; |
624 |
< |
result := EncodeTime(Word(tm_date.tm_hour), Word(tm_date.tm_min), |
625 |
< |
Word(tm_date.tm_sec), msecs) |
623 |
> |
DMs := PISC_TIME(bufptr)^ mod 10000; |
624 |
> |
result := FBEncodeTime(Word(tm_date.tm_hour), Word(tm_date.tm_min), |
625 |
> |
Word(tm_date.tm_sec), DMs) |
626 |
|
except |
627 |
|
on E: EConvertError do begin |
628 |
|
IBError(ibxeInvalidDataConversion, [nil]); |
634 |
|
var |
635 |
|
tm_date: TCTimeStructure; |
636 |
|
Yr, Mn, Dy, Hr, Mt, S, Ms: Word; |
637 |
+ |
DMs: cardinal; |
638 |
|
begin |
639 |
|
DecodeDate(aDateTime, Yr, Mn, Dy); |
640 |
< |
DecodeTime(aDateTime, Hr, Mt, S, Ms); |
640 |
> |
FBDecodeTime(aDateTime, Hr, Mt, S, DMs); |
641 |
|
with tm_date do begin |
642 |
|
tm_sec := S; |
643 |
|
tm_min := Mt; |
647 |
|
tm_year := Yr - 1900; |
648 |
|
end; |
649 |
|
isc_encode_date(@tm_date, PISC_QUAD(bufptr)); |
650 |
< |
if Ms > 0 then |
651 |
< |
Inc(PISC_TIMESTAMP(bufptr)^.timestamp_time,Ms*10); |
650 |
> |
if DMs > 0 then |
651 |
> |
Inc(PISC_TIMESTAMP(bufptr)^.timestamp_time,DMs); |
652 |
|
end; |
653 |
|
|
654 |
|
function TFB25ClientAPI.SQLDecodeDateTime(bufptr: PByte): TDateTime; |
655 |
|
var |
656 |
|
tm_date: TCTimeStructure; |
657 |
< |
msecs: Word; |
657 |
> |
Dmsecs: Word; |
658 |
|
begin |
659 |
|
isc_decode_date(PISC_QUAD(bufptr), @tm_date); |
660 |
|
try |
661 |
|
result := EncodeDate(Word(tm_date.tm_year + 1900), Word(tm_date.tm_mon + 1), |
662 |
|
Word(tm_date.tm_mday)); |
663 |
< |
msecs := (PISC_TIMESTAMP(bufptr)^.timestamp_time mod 10000) div 10; |
663 |
> |
Dmsecs := PISC_TIMESTAMP(bufptr)^.timestamp_time mod 10000; |
664 |
|
if result >= 0 then |
665 |
< |
result := result + EncodeTime(Word(tm_date.tm_hour), Word(tm_date.tm_min), |
666 |
< |
Word(tm_date.tm_sec), msecs) |
665 |
> |
result := result + FBEncodeTime(Word(tm_date.tm_hour), Word(tm_date.tm_min), |
666 |
> |
Word(tm_date.tm_sec), Dmsecs) |
667 |
|
else |
668 |
< |
result := result - EncodeTime(Word(tm_date.tm_hour), Word(tm_date.tm_min), |
669 |
< |
Word(tm_date.tm_sec), msecs) |
668 |
> |
result := result - FBEncodeTime(Word(tm_date.tm_hour), Word(tm_date.tm_min), |
669 |
> |
Word(tm_date.tm_sec), Dmsecs) |
670 |
|
except |
671 |
|
on E: EConvertError do begin |
672 |
|
IBError(ibxeInvalidDataConversion, [nil]); |
674 |
|
end; |
675 |
|
end; |
676 |
|
|
677 |
+ |
function TFB25ClientAPI.FormatStatus(Status: TFBStatus): AnsiString; |
678 |
+ |
var psb: PStatusVector; |
679 |
+ |
local_buffer: array[0..IBHugeLocalBufferLength - 1] of AnsiChar; |
680 |
+ |
begin |
681 |
+ |
psb := Status.StatusVector; |
682 |
+ |
Result := ''; |
683 |
+ |
while isc_interprete(@local_buffer,@psb) > 0 do |
684 |
+ |
begin |
685 |
+ |
if (Result <> '') and (Result[Length(Result)] <> LF) then |
686 |
+ |
Result := Result + LineEnding + '-'; |
687 |
+ |
Result := Result + strpas(local_buffer); |
688 |
+ |
end; |
689 |
+ |
end; |
690 |
+ |
|
691 |
|
end. |
692 |
|
|
693 |
|
|