41 |
|
Classes, SysUtils, {$IFDEF WINDOWS} windows, {$ENDIF} IB, FBParamBlock, |
42 |
|
FBActivityMonitor, FBClientAPI; |
43 |
|
|
44 |
+ |
const |
45 |
+ |
DefaultMaxInlineBlobLimit = 8192; |
46 |
+ |
|
47 |
|
type |
48 |
|
TCharsetMap = record |
49 |
|
CharsetID: integer; |
63 |
|
FODSMinorVersion: integer; |
64 |
|
FUserCharSetMap: array of TCharSetMap; |
65 |
|
FSecDatabase: AnsiString; |
66 |
+ |
FInlineBlobLimit: integer; |
67 |
|
protected |
68 |
|
FDatabaseName: AnsiString; |
69 |
|
FRaiseExceptionOnConnectError: boolean; |
101 |
|
function ExecuteSQL(transaction: ITransaction; sql: AnsiString; SQLDialect: integer; params: array of const): IResults; overload; |
102 |
|
function ExecuteSQL(TPB: array of byte; sql: AnsiString; params: array of const): IResults; overload; |
103 |
|
function ExecuteSQL(transaction: ITransaction; sql: AnsiString; params: array of const): IResults; overload; |
104 |
< |
function OpenCursor(transaction: ITransaction; sql: AnsiString; aSQLDialect: integer): IResultSet; overload; |
104 |
> |
function OpenCursor(transaction: ITransaction; sql: AnsiString; aSQLDialect: integer; |
105 |
> |
Scrollable: boolean=false): IResultSet; overload; |
106 |
|
function OpenCursor(transaction: ITransaction; sql: AnsiString; aSQLDialect: integer; |
107 |
|
params: array of const): IResultSet; overload; |
108 |
< |
function OpenCursor(transaction: ITransaction; sql: AnsiString): IResultSet; overload; |
108 |
> |
function OpenCursor(transaction: ITransaction; sql: AnsiString; Scrollable: boolean=false): IResultSet; overload; |
109 |
|
function OpenCursor(transaction: ITransaction; sql: AnsiString; |
110 |
|
params: array of const): IResultSet; overload; |
111 |
< |
function OpenCursorAtStart(transaction: ITransaction; sql: AnsiString; aSQLDialect: integer): IResultSet; overload; |
111 |
> |
function OpenCursor(transaction: ITransaction; sql: AnsiString; Scrollable: boolean; |
112 |
> |
params: array of const): IResultSet; overload; |
113 |
> |
function OpenCursor(transaction: ITransaction; sql: AnsiString; aSQLDialect: integer; Scrollable: boolean; |
114 |
> |
params: array of const): IResultSet; overload; |
115 |
> |
function OpenCursorAtStart(transaction: ITransaction; sql: AnsiString; aSQLDialect: integer; |
116 |
> |
Scrollable: boolean=false): IResultSet; overload; |
117 |
|
function OpenCursorAtStart(transaction: ITransaction; sql: AnsiString; aSQLDialect: integer; |
118 |
|
params: array of const): IResultSet; overload; |
119 |
< |
function OpenCursorAtStart(transaction: ITransaction; sql: AnsiString): IResultSet; overload; |
119 |
> |
function OpenCursorAtStart(transaction: ITransaction; sql: AnsiString; aSQLDialect: integer; Scrollable: boolean; |
120 |
> |
params: array of const): IResultSet; overload; |
121 |
> |
function OpenCursorAtStart(transaction: ITransaction; sql: AnsiString; Scrollable: boolean=false): IResultSet; overload; |
122 |
|
function OpenCursorAtStart(transaction: ITransaction; sql: AnsiString; |
123 |
|
params: array of const): IResultSet; overload; |
124 |
< |
function OpenCursorAtStart(sql: AnsiString): IResultSet; overload; |
124 |
> |
function OpenCursorAtStart(transaction: ITransaction; sql: AnsiString; Scrollable: boolean; |
125 |
> |
params: array of const): IResultSet; overload; |
126 |
> |
function OpenCursorAtStart(sql: AnsiString;Scrollable: boolean=false): IResultSet; overload; |
127 |
> |
function OpenCursorAtStart(sql: AnsiString; Scrollable: boolean; |
128 |
> |
params: array of const): IResultSet; overload; |
129 |
|
function OpenCursorAtStart(sql: AnsiString; |
130 |
|
params: array of const): IResultSet; overload; |
131 |
< |
function Prepare(transaction: ITransaction; sql: AnsiString; aSQLDialect: integer): IStatement; overload; virtual; abstract; |
132 |
< |
function Prepare(transaction: ITransaction; sql: AnsiString): IStatement; overload; |
131 |
> |
function Prepare(transaction: ITransaction; sql: AnsiString; aSQLDialect: integer; CursorName: AnsiString=''): IStatement; overload; virtual; abstract; |
132 |
> |
function Prepare(transaction: ITransaction; sql: AnsiString; CursorName: AnsiString=''): IStatement; overload; |
133 |
|
function PrepareWithNamedParameters(transaction: ITransaction; sql: AnsiString; |
134 |
|
aSQLDialect: integer; GenerateParamNames: boolean=false; |
135 |
< |
CaseSensitiveParams: boolean = false): IStatement; overload; virtual; abstract; |
135 |
> |
CaseSensitiveParams: boolean = false; CursorName: AnsiString=''): IStatement; overload; virtual; abstract; |
136 |
|
function PrepareWithNamedParameters(transaction: ITransaction; sql: AnsiString; |
137 |
|
GenerateParamNames: boolean=false; |
138 |
< |
CaseSensitiveParams: boolean = false): IStatement; overload; |
138 |
> |
CaseSensitiveParams: boolean = false; CursorName: AnsiString=''): IStatement; overload; |
139 |
|
function GetEventHandler(Events: TStrings): IEvents; overload; virtual; abstract; |
140 |
|
function GetEventHandler(Event: AnsiString): IEvents; overload; |
141 |
|
|
163 |
|
function GetODSMajorVersion: integer; |
164 |
|
function GetODSMinorVersion: integer; |
165 |
|
function HasDecFloatSupport: boolean; virtual; |
166 |
+ |
function GetInlineBlobLimit: integer; |
167 |
+ |
procedure SetInlineBlobLimit(limit: integer); |
168 |
+ |
function HasBatchMode: boolean; virtual; |
169 |
|
|
170 |
|
public |
171 |
|
{Character Sets} |
204 |
|
function LookupItemType(ParamTypeName: AnsiString): byte; override; |
205 |
|
public |
206 |
|
constructor Create(api: TFBClientAPI); |
207 |
+ |
function GetParamTypeName(ParamType: byte): Ansistring; |
208 |
+ |
{$IFDEF FPC} |
209 |
+ |
function IDPB.GetDPBParamTypeName = GetParamTypeName; |
210 |
+ |
{$ELSE} |
211 |
|
function GetDPBParamTypeName(ParamType: byte): Ansistring; |
212 |
+ |
{$ENDIF} |
213 |
|
end; |
214 |
|
|
215 |
|
implementation |
475 |
|
FRaiseExceptionOnConnectError := RaiseExceptionOnConnectError; |
476 |
|
FODSMajorVersion := 0; |
477 |
|
FODSMinorVersion := 0; |
478 |
+ |
FInlineBlobLimit := DefaultMaxInlineBlobLimit; |
479 |
|
end; |
480 |
|
|
481 |
|
function TFBAttachment.GenerateCreateDatabaseSQL(DatabaseName: AnsiString; aDPB: IDPB): AnsiString; |
689 |
|
end; |
690 |
|
|
691 |
|
function TFBAttachment.OpenCursor(transaction: ITransaction; sql: AnsiString; |
692 |
< |
aSQLDialect: integer): IResultSet; |
692 |
> |
aSQLDialect: integer; Scrollable: boolean): IResultSet; |
693 |
|
begin |
694 |
< |
Result := OpenCursor(transaction,sql,aSQLDialect,[]); |
694 |
> |
Result := OpenCursor(transaction,sql,aSQLDialect,Scrollable,[]); |
695 |
|
end; |
696 |
|
|
697 |
|
function TFBAttachment.OpenCursor(transaction: ITransaction; sql: AnsiString; |
698 |
|
aSQLDialect: integer; params: array of const): IResultSet; |
699 |
< |
var Statement: IStatement; |
699 |
> |
|
700 |
|
begin |
701 |
< |
CheckHandle; |
677 |
< |
Statement := Prepare(transaction,sql,aSQLDialect); |
678 |
< |
SetParameters(Statement.SQLParams,params); |
679 |
< |
Result := Statement.OpenCursor; |
701 |
> |
Result := OpenCursor(transaction,sql,FSQLDialect,false,params); |
702 |
|
end; |
703 |
|
|
704 |
< |
function TFBAttachment.OpenCursor(transaction: ITransaction; sql: AnsiString |
705 |
< |
): IResultSet; |
704 |
> |
function TFBAttachment.OpenCursor(transaction: ITransaction; sql: AnsiString; |
705 |
> |
Scrollable: boolean): IResultSet; |
706 |
|
begin |
707 |
< |
Result := OpenCursor(transaction,sql,FSQLDialect,[]); |
707 |
> |
Result := OpenCursor(transaction,sql,FSQLDialect,Scrollable,[]); |
708 |
|
end; |
709 |
|
|
710 |
|
function TFBAttachment.OpenCursor(transaction: ITransaction; sql: AnsiString; |
711 |
|
params: array of const): IResultSet; |
712 |
|
begin |
713 |
< |
Result := OpenCursor(transaction,sql,FSQLDialect,params); |
713 |
> |
Result := OpenCursor(transaction,sql,FSQLDialect,false,params); |
714 |
> |
end; |
715 |
> |
|
716 |
> |
function TFBAttachment.OpenCursor(transaction: ITransaction; sql: AnsiString; |
717 |
> |
Scrollable: boolean; params: array of const): IResultSet; |
718 |
> |
begin |
719 |
> |
Result := OpenCursor(transaction,sql,FSQLDialect,Scrollable,params); |
720 |
> |
end; |
721 |
> |
|
722 |
> |
function TFBAttachment.OpenCursor(transaction: ITransaction; sql: AnsiString; |
723 |
> |
aSQLDialect: integer; Scrollable: boolean; |
724 |
> |
params: array of const): IResultSet; |
725 |
> |
var Statement: IStatement; |
726 |
> |
begin |
727 |
> |
CheckHandle; |
728 |
> |
Statement := Prepare(transaction,sql,aSQLDialect); |
729 |
> |
SetParameters(Statement.SQLParams,params); |
730 |
> |
Result := Statement.OpenCursor(Scrollable); |
731 |
|
end; |
732 |
|
|
733 |
|
function TFBAttachment.OpenCursorAtStart(transaction: ITransaction; |
734 |
< |
sql: AnsiString; aSQLDialect: integer): IResultSet; |
734 |
> |
sql: AnsiString; aSQLDialect: integer; Scrollable: boolean): IResultSet; |
735 |
|
begin |
736 |
< |
Result := OpenCursor(transaction,sql,aSQLDialect,[]); |
736 |
> |
Result := OpenCursor(transaction,sql,aSQLDialect,Scrollable,[]); |
737 |
|
Result.FetchNext; |
738 |
|
end; |
739 |
|
|
744 |
|
Result.FetchNext; |
745 |
|
end; |
746 |
|
|
747 |
< |
function TFBAttachment.OpenCursorAtStart(transaction: ITransaction; sql: AnsiString |
748 |
< |
): IResultSet; |
747 |
> |
function TFBAttachment.OpenCursorAtStart(transaction: ITransaction; |
748 |
> |
sql: AnsiString; aSQLDialect: integer; Scrollable: boolean; |
749 |
> |
params: array of const): IResultSet; |
750 |
|
begin |
751 |
< |
Result := OpenCursorAtStart(transaction,sql,FSQLDialect,[]); |
751 |
> |
Result := OpenCursor(transaction,sql,aSQLDialect,Scrollable,params); |
752 |
> |
Result.FetchNext; |
753 |
> |
end; |
754 |
> |
|
755 |
> |
function TFBAttachment.OpenCursorAtStart(transaction: ITransaction; |
756 |
> |
sql: AnsiString; Scrollable: boolean): IResultSet; |
757 |
> |
begin |
758 |
> |
Result := OpenCursorAtStart(transaction,sql,FSQLDialect,Scrollable,[]); |
759 |
|
end; |
760 |
|
|
761 |
|
function TFBAttachment.OpenCursorAtStart(transaction: ITransaction; |
764 |
|
Result := OpenCursorAtStart(transaction,sql,FSQLDialect,params); |
765 |
|
end; |
766 |
|
|
767 |
< |
function TFBAttachment.OpenCursorAtStart(sql: AnsiString): IResultSet; |
767 |
> |
function TFBAttachment.OpenCursorAtStart(transaction: ITransaction; |
768 |
> |
sql: AnsiString; Scrollable: boolean; params: array of const): IResultSet; |
769 |
> |
begin |
770 |
> |
Result := OpenCursorAtStart(transaction,sql,FSQLDialect,Scrollable,params); |
771 |
> |
end; |
772 |
> |
|
773 |
> |
function TFBAttachment.OpenCursorAtStart(sql: AnsiString; Scrollable: boolean |
774 |
> |
): IResultSet; |
775 |
> |
begin |
776 |
> |
Result := OpenCursorAtStart(sql,Scrollable,[]); |
777 |
> |
end; |
778 |
> |
|
779 |
> |
function TFBAttachment.OpenCursorAtStart(sql: AnsiString; Scrollable: boolean; |
780 |
> |
params: array of const): IResultSet; |
781 |
|
begin |
782 |
< |
Result := OpenCursorAtStart(sql,[]); |
782 |
> |
Result := OpenCursorAtStart(StartTransaction([isc_tpb_read,isc_tpb_wait,isc_tpb_concurrency],taCommit),sql,FSQLDialect, |
783 |
> |
Scrollable,params); |
784 |
|
end; |
785 |
|
|
786 |
|
function TFBAttachment.OpenCursorAtStart(sql: AnsiString; |
787 |
|
params: array of const): IResultSet; |
788 |
|
begin |
789 |
< |
Result := OpenCursorAtStart(StartTransaction([isc_tpb_read,isc_tpb_wait,isc_tpb_concurrency],taCommit),sql,FSQLDialect,params); |
789 |
> |
Result := OpenCursorAtStart(StartTransaction([isc_tpb_read,isc_tpb_wait,isc_tpb_concurrency],taCommit),sql,FSQLDialect, |
790 |
> |
false,params); |
791 |
|
end; |
792 |
|
|
793 |
< |
function TFBAttachment.Prepare(transaction: ITransaction; sql: AnsiString |
794 |
< |
): IStatement; |
793 |
> |
function TFBAttachment.Prepare(transaction: ITransaction; sql: AnsiString; |
794 |
> |
CursorName: AnsiString): IStatement; |
795 |
|
begin |
796 |
< |
Result := Prepare(transaction,sql,FSQLDialect); |
796 |
> |
Result := Prepare(transaction,sql,FSQLDialect,CursorName); |
797 |
|
end; |
798 |
|
|
799 |
|
function TFBAttachment.PrepareWithNamedParameters(transaction: ITransaction; |
800 |
< |
sql: AnsiString; GenerateParamNames: boolean; CaseSensitiveParams: boolean): IStatement; |
800 |
> |
sql: AnsiString; GenerateParamNames: boolean; CaseSensitiveParams: boolean; |
801 |
> |
CursorName: AnsiString): IStatement; |
802 |
|
begin |
803 |
< |
Result := PrepareWithNamedParameters(transaction,sql,FSQLDialect,GenerateParamNames,CaseSensitiveParams); |
803 |
> |
Result := PrepareWithNamedParameters(transaction,sql,FSQLDialect,GenerateParamNames,CaseSensitiveParams,CursorName); |
804 |
|
end; |
805 |
|
|
806 |
|
function TFBAttachment.GetEventHandler(Event: AnsiString): IEvents; |
924 |
|
Result := false; |
925 |
|
end; |
926 |
|
|
927 |
+ |
function TFBAttachment.GetInlineBlobLimit: integer; |
928 |
+ |
begin |
929 |
+ |
Result := FInlineBlobLimit; |
930 |
+ |
end; |
931 |
+ |
|
932 |
+ |
procedure TFBAttachment.SetInlineBlobLimit(limit: integer); |
933 |
+ |
begin |
934 |
+ |
if limit > 32*1024 then |
935 |
+ |
FInlineBlobLimit := 32*1024 |
936 |
+ |
else |
937 |
+ |
FInlineBlobLimit := limit; |
938 |
+ |
end; |
939 |
+ |
|
940 |
+ |
function TFBAttachment.HasBatchMode: boolean; |
941 |
+ |
begin |
942 |
+ |
Result := false; |
943 |
+ |
end; |
944 |
+ |
|
945 |
|
function TFBAttachment.HasDefaultCharSet: boolean; |
946 |
|
begin |
947 |
|
Result := FHasDefaultCharSet |
1112 |
|
FBuffer^ := isc_dpb_version1; |
1113 |
|
end; |
1114 |
|
|
1115 |
< |
function TDPB.GetDPBParamTypeName(ParamType: byte): Ansistring; |
1115 |
> |
function TDPB.GetParamTypeName(ParamType: byte): Ansistring; |
1116 |
|
begin |
1117 |
|
if ParamType <= isc_dpb_last_dpb_constant then |
1118 |
|
Result := DPBConstantNames[ParamType] |
1120 |
|
Result := ''; |
1121 |
|
end; |
1122 |
|
|
1123 |
+ |
{$IFNDEF FPC} |
1124 |
+ |
function TDPB.GetDPBParamTypeName(ParamType: byte): Ansistring; |
1125 |
+ |
begin |
1126 |
+ |
Result := GetParamTypeName(ParamType); |
1127 |
+ |
end; |
1128 |
+ |
{$ENDIF} |
1129 |
+ |
|
1130 |
|
function TDPB.LookupItemType(ParamTypeName: AnsiString): byte; |
1131 |
|
var i: byte; |
1132 |
|
begin |