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; |
146 |
|
isc_detach_database: Tisc_detach_database; |
147 |
|
isc_attach_database: Tisc_attach_database; |
148 |
|
isc_database_info: Tisc_database_info; |
149 |
+ |
isc_transaction_info: Tisc_transaction_info; |
150 |
|
isc_start_transaction: Tisc_start_transaction; |
151 |
|
isc_start_multiple: Tisc_start_multiple; |
152 |
|
isc_commit_transaction: Tisc_commit_transaction; |
163 |
|
isc_array_put_slice: Tisc_array_put_slice; |
164 |
|
isc_prepare_transaction: Tisc_prepare_transaction; |
165 |
|
isc_version: Tisc_Version; |
166 |
+ |
isc_interprete: Tisc_interprete; |
167 |
|
|
168 |
|
public |
169 |
|
{Helper Functions} |
172 |
– |
function DecodeInteger(bufptr: PByte; len: short): integer; override; |
170 |
|
procedure SQLEncodeDate(aDate: TDateTime; bufptr: PByte); override; |
171 |
|
function SQLDecodeDate(bufptr: PByte): TDateTime; override; |
172 |
|
procedure SQLEncodeTime(aTime: TDateTime; bufptr: PByte); override; |
173 |
|
function SQLDecodeTime(bufptr: PByte): TDateTime; override; |
174 |
|
procedure SQLEncodeDateTime(aDateTime: TDateTime; bufptr: PByte); override; |
175 |
|
function SQLDecodeDateTime(bufptr: PByte): TDateTime; override; |
176 |
< |
|
176 |
> |
function FormatStatus(Status: TFBStatus): AnsiString; override; |
177 |
|
public |
178 |
|
{IFirebirdAPI} |
179 |
|
|
200 |
|
function GetStatus: IStatus; override; |
201 |
|
function HasRollbackRetaining: boolean; |
202 |
|
function IsEmbeddedServer: boolean; override; |
203 |
< |
function GetImplementationVersion: AnsiString; |
203 |
> |
function GetClientMajor: integer; override; |
204 |
> |
function GetClientMinor: integer; override; |
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} |
368 |
|
isc_detach_database := GetProcAddr('isc_detach_database'); {do not localize} |
369 |
|
isc_attach_database := GetProcAddr('isc_attach_database'); {do not localize} |
370 |
|
isc_database_info := GetProcAddr('isc_database_info'); {do not localize} |
371 |
+ |
isc_transaction_info := GetProcAddr('isc_transaction_info'); {do not localize} |
372 |
|
isc_start_transaction := GetProcAddr('isc_start_transaction'); {do not localize} |
373 |
|
isc_start_multiple := GetProcAddr('isc_start_multiple'); {do not localize} |
374 |
|
isc_commit_transaction := GetProcAddr('isc_commit_transaction'); {do not localize} |
384 |
|
isc_array_put_slice := GetProcAddr('isc_array_put_slice'); {do not localize} |
385 |
|
isc_prepare_transaction := GetProcAddr('isc_prepare_transaction'); {do not localize} |
386 |
|
isc_version := GetProcAddr('isc_version'); {do not localize} |
387 |
+ |
isc_interprete := GetProcAddr('isc_interprete'); {do not localize} |
388 |
|
|
389 |
|
FIBServiceAPIPresent := true; |
390 |
|
isc_rollback_retaining := GetProcAddress(FFBLibrary.IBLibrary, 'isc_rollback_retaining'); {do not localize} |
537 |
|
{$ENDIF} |
538 |
|
end; |
539 |
|
|
540 |
< |
function TFB25ClientAPI.HasMasterIntf: boolean; |
540 |
> |
function TFB25ClientAPI.GetClientMajor: integer; |
541 |
|
begin |
542 |
< |
Result := false; |
542 |
> |
Result := 2; |
543 |
|
end; |
544 |
|
|
545 |
< |
function TFB25ClientAPI.GetIMaster: TObject; |
545 |
> |
function TFB25ClientAPI.GetClientMinor: integer; |
546 |
|
begin |
547 |
< |
Result := nil; |
547 |
> |
Result := 5; |
548 |
|
end; |
549 |
|
|
550 |
< |
function TFB25ClientAPI.GetImplementationVersion: AnsiString; |
550 |
> |
function TFB25ClientAPI.HasMasterIntf: boolean; |
551 |
|
begin |
552 |
< |
Result := FBClientInterfaceVersion; |
552 |
> |
Result := false; |
553 |
|
end; |
554 |
|
|
555 |
< |
function TFB25ClientAPI.DecodeInteger(bufptr: PByte; len: short): integer; |
555 |
> |
function TFB25ClientAPI.GetIMaster: TObject; |
556 |
|
begin |
557 |
< |
Result := isc_portable_integer(bufptr,len); |
557 |
> |
Result := nil; |
558 |
|
end; |
559 |
|
|
560 |
|
procedure TFB25ClientAPI.SQLEncodeDate(aDate: TDateTime; bufptr: PByte); |
592 |
|
procedure TFB25ClientAPI.SQLEncodeTime(aTime: TDateTime; bufptr: PByte); |
593 |
|
var |
594 |
|
tm_date: TCTimeStructure; |
595 |
< |
Hr, Mt, S, Ms: Word; |
595 |
> |
Hr, Mt, S: Word; |
596 |
> |
DMs: cardinal; {DMs = decimilliseconds} |
597 |
|
begin |
598 |
< |
DecodeTime(aTime, Hr, Mt, S, Ms); |
598 |
> |
FBDecodeTime(aTime, Hr, Mt, S, DMs); |
599 |
|
with tm_date do begin |
600 |
|
tm_sec := S; |
601 |
|
tm_min := Mt; |
605 |
|
tm_year := 0; |
606 |
|
end; |
607 |
|
isc_encode_sql_time(@tm_date, PISC_TIME(bufptr)); |
608 |
< |
if Ms > 0 then |
609 |
< |
Inc(PISC_TIME(bufptr)^,Ms*10); |
608 |
> |
if DMs > 0 then |
609 |
> |
Inc(PISC_TIME(bufptr)^,DMs); |
610 |
|
end; |
611 |
|
|
612 |
|
function TFB25ClientAPI.SQLDecodeTime(bufptr: PByte): TDateTime; |
613 |
|
var |
614 |
|
tm_date: TCTimeStructure; |
615 |
< |
msecs: Word; |
615 |
> |
DMs: cardinal; {DMs = decimilliseconds} |
616 |
|
begin |
617 |
|
isc_decode_sql_time(PISC_TIME(bufptr), @tm_date); |
618 |
|
try |
619 |
< |
msecs := (PISC_TIME(bufptr)^ mod 10000) div 10; |
620 |
< |
result := EncodeTime(Word(tm_date.tm_hour), Word(tm_date.tm_min), |
621 |
< |
Word(tm_date.tm_sec), msecs) |
619 |
> |
DMs := PISC_TIME(bufptr)^ mod 10000; |
620 |
> |
result := FBEncodeTime(Word(tm_date.tm_hour), Word(tm_date.tm_min), |
621 |
> |
Word(tm_date.tm_sec), DMs) |
622 |
|
except |
623 |
|
on E: EConvertError do begin |
624 |
|
IBError(ibxeInvalidDataConversion, [nil]); |
630 |
|
var |
631 |
|
tm_date: TCTimeStructure; |
632 |
|
Yr, Mn, Dy, Hr, Mt, S, Ms: Word; |
633 |
+ |
DMs: cardinal; |
634 |
|
begin |
635 |
|
DecodeDate(aDateTime, Yr, Mn, Dy); |
636 |
< |
DecodeTime(aDateTime, Hr, Mt, S, Ms); |
636 |
> |
FBDecodeTime(aDateTime, Hr, Mt, S, DMs); |
637 |
|
with tm_date do begin |
638 |
|
tm_sec := S; |
639 |
|
tm_min := Mt; |
643 |
|
tm_year := Yr - 1900; |
644 |
|
end; |
645 |
|
isc_encode_date(@tm_date, PISC_QUAD(bufptr)); |
646 |
< |
if Ms > 0 then |
647 |
< |
Inc(PISC_TIMESTAMP(bufptr)^.timestamp_time,Ms*10); |
646 |
> |
if DMs > 0 then |
647 |
> |
Inc(PISC_TIMESTAMP(bufptr)^.timestamp_time,DMs); |
648 |
|
end; |
649 |
|
|
650 |
|
function TFB25ClientAPI.SQLDecodeDateTime(bufptr: PByte): TDateTime; |
651 |
|
var |
652 |
|
tm_date: TCTimeStructure; |
653 |
< |
msecs: Word; |
653 |
> |
Dmsecs: Word; |
654 |
|
begin |
655 |
|
isc_decode_date(PISC_QUAD(bufptr), @tm_date); |
656 |
|
try |
657 |
|
result := EncodeDate(Word(tm_date.tm_year + 1900), Word(tm_date.tm_mon + 1), |
658 |
|
Word(tm_date.tm_mday)); |
659 |
< |
msecs := (PISC_TIMESTAMP(bufptr)^.timestamp_time mod 10000) div 10; |
659 |
> |
Dmsecs := PISC_TIMESTAMP(bufptr)^.timestamp_time mod 10000; |
660 |
|
if result >= 0 then |
661 |
< |
result := result + EncodeTime(Word(tm_date.tm_hour), Word(tm_date.tm_min), |
662 |
< |
Word(tm_date.tm_sec), msecs) |
661 |
> |
result := result + FBEncodeTime(Word(tm_date.tm_hour), Word(tm_date.tm_min), |
662 |
> |
Word(tm_date.tm_sec), Dmsecs) |
663 |
|
else |
664 |
< |
result := result - EncodeTime(Word(tm_date.tm_hour), Word(tm_date.tm_min), |
665 |
< |
Word(tm_date.tm_sec), msecs) |
664 |
> |
result := result - FBEncodeTime(Word(tm_date.tm_hour), Word(tm_date.tm_min), |
665 |
> |
Word(tm_date.tm_sec), Dmsecs) |
666 |
|
except |
667 |
|
on E: EConvertError do begin |
668 |
|
IBError(ibxeInvalidDataConversion, [nil]); |
670 |
|
end; |
671 |
|
end; |
672 |
|
|
673 |
+ |
function TFB25ClientAPI.FormatStatus(Status: TFBStatus): AnsiString; |
674 |
+ |
var psb: PStatusVector; |
675 |
+ |
local_buffer: array[0..IBHugeLocalBufferLength - 1] of AnsiChar; |
676 |
+ |
begin |
677 |
+ |
psb := Status.StatusVector; |
678 |
+ |
Result := ''; |
679 |
+ |
while isc_interprete(@local_buffer,@psb) > 0 do |
680 |
+ |
begin |
681 |
+ |
if (Result <> '') and (Result[Length(Result)] <> LF) then |
682 |
+ |
Result := Result + LineEnding + '-'; |
683 |
+ |
Result := Result + strpas(local_buffer); |
684 |
+ |
end; |
685 |
+ |
end; |
686 |
+ |
|
687 |
|
end. |
688 |
|
|
689 |
|
|