ViewVC Help
View File | Revision Log | Show Annotations | Download File | View Changeset | Root Listing
root/public/ibx/branches/udr/client/FBAttachment.pas
(Generate patch)

Comparing ibx/branches/udr/client/FBAttachment.pas (file contents):
Revision 371 by tony, Wed Jan 5 15:21:22 2022 UTC vs.
Revision 375 by tony, Sun Jan 9 23:42:58 2022 UTC

# Line 141 | Line 141 | type
141      FSecDatabase: AnsiString;
142      FInlineBlobLimit: integer;
143      FAttachmentID: integer;
144  protected
145    FDatabaseName: AnsiString;
146    FRaiseExceptionOnConnectError: boolean;
144      FSQLDialect: integer;
145      FHasDefaultCharSet: boolean;
146      FCharSetID: integer;
147      FCodePage: TSystemCodePage;
148      FRemoteProtocol: AnsiString;
149      FAuthMethod: AnsiString;
150 +    FHasConnectionInfo: boolean;
151 +    procedure NeedDBInfo;
152 +    procedure NeedConnectionInfo;
153 +  protected
154 +    FDatabaseName: AnsiString;
155 +    FRaiseExceptionOnConnectError: boolean;
156      constructor Create(api: TFBClientAPI; DatabaseName: AnsiString; DPB: IDPB;
157        RaiseExceptionOnConnectError: boolean);
158      procedure CheckHandle; virtual; abstract;
159 +    procedure ClearCachedInfo;
160      function GenerateCreateDatabaseSQL(DatabaseName: AnsiString; aDPB: IDPB): AnsiString;
157    procedure GetODSAndConnectionInfo;
161      function GetDBInfo(ReqBuffer: PByte; ReqBufLen: integer): IDBInformation; virtual; abstract;
162      function IsConnected: boolean; virtual; abstract;
163      procedure EndAllTransactions;
164      procedure DPBFromCreateSQL(CreateSQL: AnsiString);
165      procedure SetParameters(SQLParams: ISQLParams; params: array of const);
166 +    procedure SetSQLDialect(aValue: integer);
167      procedure UseServerICUChanged; virtual;
168    public
169      destructor Destroy; override;
170 +    procedure Disconnect(Force: boolean); override;
171      function getFirebirdAPI: IFirebirdAPI;
172      function getDPB: IDPB;
173      function AllocateBPB: IBPB;
# Line 230 | Line 235 | type
235      function CreateArray(transaction: ITransaction; ArrayMetaData: IArrayMetaData): IArray; overload; virtual; abstract;
236      function OpenArray(transaction: ITransaction; RelationName, ColumnName: AnsiString; ArrayID: TISC_QUAD): IArray; overload;
237      function OpenArray(transaction: ITransaction; ArrayMetaData: IArrayMetaData; ArrayID: TISC_QUAD): IArray; overload; virtual; abstract;
238 <    property SQLDialect: integer read FSQLDialect;
238 >    property SQLDialect: integer read GetSQLDialect;
239      property DPB: IDPB read FDPB;
240    public
241      function GetDBInformation(Requests: array of byte): IDBInformation; overload;
# Line 264 | Line 269 | type
269        AllowReverseLookup:boolean; out CharSetID: integer);
270      function GetBlobMetaData(Transaction: ITransaction; tableName, columnName: AnsiString): IBlobMetaData; virtual; abstract;
271      function GetArrayMetaData(Transaction: ITransaction; tableName, columnName: AnsiString): IArrayMetaData; virtual; abstract;
272 <    property CharSetID: integer read FCharSetID;
272 >    property CharSetID: integer read GetCharSetID;
273      property CodePage: TSystemCodePage read FCodePage;
274  
275    public
# Line 776 | Line 781 | begin
781    EndSession(RetainJournal);
782   end;
783  
779
780
781
784   { TFBAttachment }
785  
786 < procedure TFBAttachment.GetODSAndConnectionInfo;
787 < var DBInfo: IDBInformation;
786 <    i: integer;
787 <    Stmt: IStatement;
786 > procedure TFBAttachment.NeedConnectionInfo;
787 > var Stmt: IStatement;
788      ResultSet: IResultSet;
789      Param: IDPBItem;
790   begin
791 <  if not IsConnected then Exit;
792 <  DBInfo := GetDBInformation([isc_info_db_id,isc_info_ods_version,isc_info_ods_minor_version,
793 <                               isc_info_db_SQL_Dialect, isc_info_attachment_id]);
794 <  for i := 0 to DBInfo.GetCount - 1 do
795 <    with DBInfo[i] do
796 <      case getItemType of
797 <      isc_info_ods_minor_version:
798 <        FODSMinorVersion := getAsInteger;
799 <      isc_info_ods_version:
800 <        FODSMajorVersion := getAsInteger;
801 <      isc_info_db_SQL_Dialect:
802 <        FSQLDialect := getAsInteger;
803 <      isc_info_attachment_id:
804 <        FAttachmentID := getAsInteger;
805 <      end;
806 <
791 >  if not IsConnected or FHasConnectionInfo then Exit;
792 >  NeedDBInfo;
793    FCharSetID := 0;
794    FRemoteProtocol := '';
795    FAuthMethod := 'Legacy_Auth';
# Line 849 | Line 835 | begin
835      end;
836    end;
837    FHasDefaultCharSet := CharSetID2CodePage(FCharSetID,FCodePage) and (FCharSetID > 1);
838 +  FHasConnectionInfo := true;
839 + end;
840 +
841 + procedure TFBAttachment.NeedDBInfo;
842 + var DBInfo: IDBInformation;
843 +    i: integer;
844 + begin
845 +  if not IsConnected or (FAttachmentID > 0) then Exit;
846 +  DBInfo := GetDBInformation([isc_info_db_id,isc_info_ods_version,isc_info_ods_minor_version,
847 +                               isc_info_db_SQL_Dialect, isc_info_attachment_id]);
848 +  for i := 0 to DBInfo.GetCount - 1 do
849 +    with DBInfo[i] do
850 +      case getItemType of
851 +      isc_info_ods_minor_version:
852 +        FODSMinorVersion := getAsInteger;
853 +      isc_info_ods_version:
854 +        FODSMajorVersion := getAsInteger;
855 +      isc_info_db_SQL_Dialect:
856 +        FSQLDialect := getAsInteger;
857 +      isc_info_attachment_id:
858 +        FAttachmentID := getAsInteger;
859 +      end;
860   end;
861  
862   constructor TFBAttachment.Create(api: TFBClientAPI; DatabaseName: AnsiString;
# Line 859 | Line 867 | begin
867    FSQLDialect := 3;
868    FDatabaseName := DatabaseName;
869    SetLength(FUserCharSetMap,0);
870 <  FODSMajorVersion := 0;
863 <  FODSMinorVersion := 0;
870 >  ClearCachedInfo;
871    FInlineBlobLimit := DefaultMaxInlineBlobLimit;
872    FDPB := DPB;
873    FRaiseExceptionOnConnectError := RaiseExceptionOnConnectError;
874   end;
875  
876 + procedure TFBAttachment.ClearCachedInfo;
877 + begin
878 +  FHasDefaultCharSet := false;
879 +  FAttachmentID := 0;
880 +  FODSMajorVersion := 0;
881 +  FODSMinorVersion := 0;
882 +  FCodePage := CP_NONE;
883 +  FCharSetID := 0;
884 +  FRemoteProtocol := '';
885 +  FAuthMethod := '';
886 +  FSecDatabase := '';
887 +  FHasConnectionInfo := false;
888 + end;
889 +
890   function TFBAttachment.GenerateCreateDatabaseSQL(DatabaseName: AnsiString;  aDPB: IDPB): AnsiString;
891   var CreateParams: AnsiString;
892      DPBItem: IDPBItem;
# Line 997 | Line 1018 | begin
1018    end;
1019   end;
1020  
1021 + procedure TFBAttachment.SetSQLDialect(aValue: integer);
1022 + begin
1023 +  FSQLDialect := aValue;
1024 + end;
1025 +
1026   procedure TFBAttachment.UseServerICUChanged;
1027   begin
1028    // Do nothing by default
# Line 1008 | Line 1034 | begin
1034    inherited Destroy;
1035   end;
1036  
1037 + procedure TFBAttachment.Disconnect(Force: boolean);
1038 + begin
1039 +  inherited Disconnect(Force);
1040 +  ClearCachedInfo;
1041 + end;
1042 +
1043   function TFBAttachment.getFirebirdAPI: IFirebirdAPI;
1044   begin
1045    Result := FFirebirdAPI;
# Line 1205 | Line 1237 | end;
1237  
1238   function TFBAttachment.GetSQLDialect: integer;
1239   begin
1240 +  NeedDBInfo;
1241    Result := FSQLDialect;
1242   end;
1243  
1244   function TFBAttachment.GetAttachmentID: integer;
1245   begin
1246 +  NeedDBInfo;
1247    Result := FAttachmentID;
1248   end;
1249  
# Line 1289 | Line 1323 | end;
1323  
1324   function TFBAttachment.GetRemoteProtocol: AnsiString;
1325   begin
1326 +  NeedConnectionInfo;
1327    Result := FRemoteProtocol;
1328   end;
1329  
1330   function TFBAttachment.GetAuthenticationMethod: AnsiString;
1331   begin
1332 +  NeedConnectionInfo;
1333    Result := FAuthMethod;
1334   end;
1335  
1336   function TFBAttachment.GetSecurityDatabase: AnsiString;
1337   begin
1338 +  NeedConnectionInfo;
1339    Result := FSecDatabase;
1340   end;
1341  
1342   function TFBAttachment.GetODSMajorVersion: integer;
1343   begin
1344 +  NeedDBInfo;
1345    Result := FODSMajorVersion;
1346   end;
1347  
1348   function TFBAttachment.GetODSMinorVersion: integer;
1349   begin
1350 +  NeedDBInfo;
1351    Result := FODSMinorVersion;
1352   end;
1353  
1354   function TFBAttachment.GetCharSetID: integer;
1355   begin
1356 +  NeedConnectionInfo;
1357    Result := FCharSetID;
1358   end;
1359  
# Line 1363 | Line 1403 | end;
1403  
1404   function TFBAttachment.HasDefaultCharSet: boolean;
1405   begin
1406 +  NeedConnectionInfo;
1407    Result := FHasDefaultCharSet
1408   end;
1409  
1410   function TFBAttachment.GetDefaultCharSetID: integer;
1411   begin
1412 +  NeedConnectionInfo;
1413    Result := FCharsetID;
1414   end;
1415  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines