ViewVC Help
View File | Revision Log | Show Annotations | Download File | View Changeset | Root Listing
root/public/ibx/branches/udr/udr/testbed/FBUdrPlugin.pas
(Generate patch)
# Line 44 | Line 44
44    Classes, SysUtils, Firebird, IB, FBUDRIntf, FBUDRController, FB30Statement;
45  
46   type
47 <  TFBUdrPlugin = class;
47 >  TFBUdrPluginEmulator = class;
48  
49    { TEmulatedExternalContext }
50  
# Line 78 | Line 78
78  
79    TEmulatedRoutineMetadata = class(IRoutineMetadataImpl)
80    private
81 <    FManager: TFBUdrPlugin;
81 >    FManager: TFBUdrPluginEmulator;
82      FName: AnsiString;
83      FPackageName: AnsiString;
84      FStatement: IStatement;
# Line 89 | Line 89
89      FOutputMetadata: firebird.IMessageMetadata;
90      FTriggerMetadata: firebird.IMessageMetadata;
91    public
92 <    constructor Create(aManager: TFBUdrPlugin; aName, aPackageName, aEntryPoint: AnsiString; aStatement: IStatement);
92 >    constructor Create(aManager: TFBUdrPluginEmulator; aName, aPackageName, aEntryPoint: AnsiString; aStatement: IStatement);
93      destructor Destroy; override;
94      procedure SetTriggerInfo(aTableName: AnsiString; aTriggerType: cardinal);
95    function AsText: AnsiString;
95    public
96      {IRoutineMetadata}
97      function getPackage(status: Firebird.IStatus): PAnsiChar; override;
# Line 110 | Line 109
109  
110    TExternalWrapper = class
111    protected
112 <    FManager: TFBUdrPlugin;
112 >    FManager: TFBUdrPluginEmulator;
113      FName: AnsiString;
114      FPreparedStatement: IStatement;
115      FContext: TEmulatedExternalContext;
# Line 126 | Line 125
125                        inBuilder: Firebird.IMetadataBuilder;
126                        outBuilder: Firebird.IMetadataBuilder); virtual; abstract;
127    public
128 <    constructor Create(aManager: TFBUdrPlugin; aName, aPackageName, aEntryPoint: AnsiString;
128 >    constructor Create(aManager: TFBUdrPluginEmulator; aName, aPackageName, aEntryPoint: AnsiString;
129                                   preparedStmt: IStatement);
130      destructor Destroy; override;
131    end;
# Line 143 | Line 142
142                        inBuilder: Firebird.IMetadataBuilder;
143                        outBuilder: Firebird.IMetadataBuilder); override;
144    public
145 <    constructor Create(aManager: TFBUdrPlugin;aName, aPackageName, aEntryPoint: AnsiString;
145 >    constructor Create(aManager: TFBUdrPluginEmulator;aName, aPackageName, aEntryPoint: AnsiString;
146         aFunctionFactory: TFBUDRFunctionFactory;
147         preparedStmt: IStatement);
148      function Execute(aTransaction: ITransaction): ISQLData;
# Line 175 | Line 174
174                        inBuilder: Firebird.IMetadataBuilder;
175                        outBuilder: Firebird.IMetadataBuilder); override;
176    public
177 <    constructor Create(aManager: TFBUdrPlugin; aName, aPackageName, aEntryPoint: AnsiString;
177 >    constructor Create(aManager: TFBUdrPluginEmulator; aName, aPackageName, aEntryPoint: AnsiString;
178         aProcedureFactory: TFBUDRProcedureFactory;
179         preparedStmt: IStatement);
180      function Execute(aTransaction: ITransaction): IProcedureResults;
# Line 212 | Line 211
211                        inBuilder: Firebird.IMetadataBuilder;
212                        outBuilder: Firebird.IMetadataBuilder); override;
213    public
214 <    constructor Create(aManager: TFBUdrPlugin; aName,  aTableName, aEntryPoint: AnsiString;
214 >    constructor Create(aManager: TFBUdrPluginEmulator; aName,  aTableName, aEntryPoint: AnsiString;
215         aTriggerType: cardinal;
216         aTriggerFactory: TFBUDRTriggerFactory;
217         preparedStmt: IStatement);
# Line 222 | Line 221
221      property NewValues: IFBUDROutputData read FNewValues;
222    end;
223  
224 <  { TFBUdrPlugin }
224 >  { TFBUdrPluginEmulator }
225  
226 <  TFBUdrPlugin = class(Firebird.IUdrPluginImpl)
226 >  TFBUdrPluginEmulator = class(Firebird.IUdrPluginImpl)
227    private
228      FModuleName: AnsiString;
229      FTheirUnloadFlag: booleanPtr;
# Line 248 | Line 247
247    public
248      constructor Create(aModuleName: AnsiString);
249      destructor Destroy; override;
250 <    function GetExternalFunction(aFunctionName, aPackageName,
250 >    function makeFunction(aFunctionName, aPackageName,
251        aEntryPoint: AnsiString): TExternalFunctionWrapper;
252 <    function GetExternalProcedure(aProcName, aPackageName, aEntryPoint: AnsiString): TExternalProcedureWrapper;
253 <    function GetExternalTrigger(aName, aEntryPoint, datasetName: AnsiString; aTriggerType: cardinal
252 >    function makeProcedure(aProcName, aPackageName, aEntryPoint: AnsiString): TExternalProcedureWrapper;
253 >    function makeTrigger(aName, aEntryPoint, datasetName: AnsiString; aTriggerType: cardinal
254        ): TExternalTriggerWrapper;
256    function GetCharSetID: integer;
255      property Attachment: IAttachment read FAttachment write SetAttachment;
256      property ModuleName: AnsiString read FModuleName;
257    end;
# Line 275 | Line 273
273      FExternalResultSet: Firebird.IExternalResultSet;
274      FResults: IResults;
275      FIsEof: boolean;
276 <    FManager: TFBUDRPlugin;
276 >    FManager: TFBUdrPluginEmulator;
277    public
278 <    constructor Create(aManager: TFBUDRPlugin;
278 >    constructor Create(aManager: TFBUdrPluginEmulator;
279        aExternalResultSet: Firebird.IExternalResultSet;
280    aSQLRecord: TIBXOUTPUTSQLDA);
281      destructor Destroy; override;
# Line 324 | Line 322
322    FTriggerFactory.setup(status,context,metadata,outBuilder);
323   end;
324  
325 < constructor TExternalTriggerWrapper.Create(aManager: TFBUdrPlugin; aName,
325 > constructor TExternalTriggerWrapper.Create(aManager: TFBUdrPluginEmulator; aName,
326    aTableName, aEntryPoint: AnsiString; aTriggerType: cardinal;
327    aTriggerFactory: TFBUDRTriggerFactory; preparedStmt: IStatement);
328   begin
# Line 386 | Line 384
384    FProcedureFactory.setup(status,context,metadata,inBuilder,outBuilder);
385   end;
386  
387 < constructor TExternalProcedureWrapper.Create(aManager: TFBUdrPlugin; aName,
387 > constructor TExternalProcedureWrapper.Create(aManager: TFBUdrPluginEmulator; aName,
388    aPackageName, aEntryPoint: AnsiString;
389    aProcedureFactory: TFBUDRProcedureFactory; preparedStmt: IStatement);
390   begin
# Line 397 | Line 395
395   function TExternalProcedureWrapper.Execute(aTransaction: ITransaction
396    ): IProcedureResults;
397   var aProcedureInstance: Firebird.IExternalProcedure;
400    ConnectionCharSetID: integer;
401    ProcedureCharSetID: integer;
398      Buffer: array [0..512] of AnsiChar;
399      ResultsSet: IExternalResultSet;
400      OutputData: IResults;
# Line 409 | Line 405
405      Setup;
406      aProcedureInstance := FProcedureFactory.newItem(FStatus,FContext,FRoutineMetadata);
407      try
412      ConnectionCharSetID := FManager.GetCharSetID;
408        Buffer[0] := #0;
409        aProcedureInstance.getCharSet(FStatus,FContext,@Buffer,sizeof(Buffer));
410        CheckStatus;
# Line 429 | Line 424
424  
425   { TProcedureResults }
426  
427 < constructor TProcedureResults.Create(aManager: TFBUDRPlugin;
427 > constructor TProcedureResults.Create(aManager: TFBUdrPluginEmulator;
428    aExternalResultSet: Firebird.IExternalResultSet; aSQLRecord: TIBXOUTPUTSQLDA);
429   begin
430    inherited Create;
# Line 527 | Line 522
522    CheckStatus;
523   end;
524  
525 < constructor TExternalWrapper.Create(aManager: TFBUdrPlugin; aName,
525 > constructor TExternalWrapper.Create(aManager: TFBUdrPluginEmulator; aName,
526    aPackageName, aEntryPoint: AnsiString; preparedStmt: IStatement);
527   begin
528    inherited Create;
# Line 553 | Line 548
548  
549   { TEmulatedRoutineMetadata }
550  
551 < constructor TEmulatedRoutineMetadata.Create(aManager: TFBUdrPlugin; aName,
551 > constructor TEmulatedRoutineMetadata.Create(aManager: TFBUdrPluginEmulator; aName,
552    aPackageName, aEntryPoint: AnsiString; aStatement: IStatement);
553   begin
554    inherited Create;
# Line 582 | Line 577
577    FTriggerType := aTriggerType;
578   end;
579  
585 function TEmulatedRoutineMetadata.AsText: AnsiString;
586 var context: TEmulatedExternalContext;
587    fbcontext: IFBUDRExternalContext;
588 begin
589  context := TEmulatedExternalContext.Create(FStatement);
590  try
591    fbcontext := TFBUDRExternalContext.Create(nil);
592    (fbcontext as TFBUDRExternalContext).Assign(context);
593    with TFBUDRRoutineMetadata.Create(fbcontext,self) do
594     Result := AsText;
595  finally
596    context.Free;
597  end;
598 end;
599
580   function TEmulatedRoutineMetadata.getPackage(status: Firebird.IStatus
581    ): PAnsiChar;
582   begin
# Line 663 | Line 643
643  
644   { TExternalFunctionWrapper }
645  
646 < constructor TExternalFunctionWrapper.Create(aManager: TFBUdrPlugin; aName,
646 > constructor TExternalFunctionWrapper.Create(aManager: TFBUdrPluginEmulator; aName,
647    aPackageName, aEntryPoint: AnsiString;
648    aFunctionFactory: TFBUDRFunctionFactory; preparedStmt: IStatement);
649   begin
# Line 673 | Line 653
653  
654   function TExternalFunctionWrapper.Execute(aTransaction: ITransaction): ISQLData;
655   var aFunctionInstance: Firebird.IExternalFunction;
676    ConnectionCharSetID: integer;
677    FunctionCharSetID: integer;
656      Buffer: array [0..512] of AnsiChar;
657      CodePage: TSystemCodePage;
658      OutputData: IResults;
# Line 684 | Line 662
662      Setup;
663      aFunctionInstance := FFunctionFactory.newItem(FStatus,FContext,FRoutineMetadata);
664      try
687      ConnectionCharSetID := FManager.GetCharSetID;
665        Buffer[0] := #0;
666        aFunctionInstance.getCharSet(FStatus,FContext,@Buffer,sizeof(Buffer));
667        CheckStatus;
# Line 808 | Line 785
785    Result := nil;
786   end;
787  
788 < { TFBUdrPlugin }
788 > { TFBUdrPluginEmulator }
789  
790 < function TFBUdrPlugin.getMaster(): IMaster;
790 > function TFBUdrPluginEmulator.getMaster(): IMaster;
791   var MasterProvider: IFBIMasterProvider;
792   begin
793    if FirebirdAPI.HasMasterIntf and (FirebirdAPI.QueryInterface(IFBIMasterProvider,MasterProvider) = S_OK) then
# Line 819 | Line 796
796      Result := nil;
797   end;
798  
799 < procedure TFBUdrPlugin.registerFunction(status: Firebird.IStatus;
799 > procedure TFBUdrPluginEmulator.registerFunction(status: Firebird.IStatus;
800    name: PAnsiChar; factory: Firebird.IUdrFunctionFactory);
801   begin
802    FFunctionFactories.AddObject(strpas(name),factory);
803   end;
804  
805 < procedure TFBUdrPlugin.registerProcedure(status: Firebird.IStatus;
805 > procedure TFBUdrPluginEmulator.registerProcedure(status: Firebird.IStatus;
806    name: PAnsiChar; factory: Firebird.IUdrProcedureFactory);
807   begin
808    FProcedureFactories.AddObject(strpas(name),factory);
809   end;
810  
811 < procedure TFBUdrPlugin.registerTrigger(status: Firebird.IStatus;
811 > procedure TFBUdrPluginEmulator.registerTrigger(status: Firebird.IStatus;
812    name: PAnsiChar; factory: Firebird.IUdrTriggerFactory);
813   begin
814    FTriggerFactories.AddObject(strpas(name),factory);
815   end;
816  
817 < constructor TFBUdrPlugin.Create(aModuleName: AnsiString);
817 > constructor TFBUdrPluginEmulator.Create(aModuleName: AnsiString);
818   begin
819    inherited Create;
820    FModuleName := aModuleName;
# Line 849 | Line 826
826    CheckStatus;
827   end;
828  
829 < destructor TFBUdrPlugin.Destroy;
829 > destructor TFBUdrPluginEmulator.Destroy;
830   begin
831    FreeList(FFunctionFactories);
832    FreeList(FProcedureFactories);
# Line 859 | Line 836
836    inherited Destroy;
837   end;
838  
839 < procedure TFBUdrPlugin.CheckStatus;
839 > procedure TFBUdrPluginEmulator.CheckStatus;
840   var buffer: array [0..4096] of AnsiChar;
841   begin
842    with FStatus do
# Line 870 | Line 847
847      end;
848   end;
849  
850 < procedure TFBUdrPlugin.FreeList(var list: TStringList);
850 > procedure TFBUdrPluginEmulator.FreeList(var list: TStringList);
851   var i: integer;
852      obj: TObject;
853   begin
# Line 894 | Line 871
871    FreeAndNil(List);
872   end;
873  
874 < function TFBUdrPlugin.CreateSelectFunctionSQL(aFunctionName: AnsiString
874 > function TFBUdrPluginEmulator.CreateSelectFunctionSQL(aFunctionName: AnsiString
875    ): AnsiString;
876   const
877    FunctionArgsSQL =
# Line 923 | Line 900
900    Result := 'Select ' + QuoteIdentifierIfNeeded(FAttachment.GetSQLDialect,aFunctionName) + '(' + arglist + ') From RDB$DATABASE';
901   end;
902  
903 < function TFBUdrPlugin.CreateExecProcedureSQL(aProcName: AnsiString): AnsiString;
903 > function TFBUdrPluginEmulator.CreateExecProcedureSQL(aProcName: AnsiString): AnsiString;
904   const
905    sGetProcArgsSQL =
906      'SELECT * ' +
# Line 971 | Line 948
948    end;
949   end;
950  
951 < procedure TFBUdrPlugin.SetAttachment(AValue: IAttachment);
951 > procedure TFBUdrPluginEmulator.SetAttachment(AValue: IAttachment);
952   begin
953    if FAttachment = AValue then Exit;
954    if (AValue = nil) or (AValue.getFirebirdAPI = nil) or not AValue.getFirebirdAPI.HasMasterIntf then
# Line 979 | Line 956
956    FAttachment := AValue;
957   end;
958  
959 < function TFBUdrPlugin.GetExternalFunction(aFunctionName, aPackageName, aEntryPoint: AnsiString): TExternalFunctionWrapper;
959 > function TFBUdrPluginEmulator.makeFunction(aFunctionName, aPackageName,
960 >  aEntryPoint: AnsiString): TExternalFunctionWrapper;
961   var index: integer;
962      aTransaction: ITransaction;
963      aModuleName,aRoutineName,aInfo: AnsiString;
# Line 1000 | Line 978
978    end;
979   end;
980  
981 < function TFBUdrPlugin.GetExternalProcedure(aProcName, aPackageName,
981 > function TFBUdrPluginEmulator.makeProcedure(aProcName, aPackageName,
982    aEntryPoint: AnsiString): TExternalProcedureWrapper;
983   var index: integer;
984      aTransaction: ITransaction;
# Line 1021 | Line 999
999    end;
1000   end;
1001  
1002 < function TFBUdrPlugin.GetExternalTrigger(aName, aEntryPoint,
1002 > function TFBUdrPluginEmulator.makeTrigger(aName, aEntryPoint,
1003    datasetName: AnsiString; aTriggerType: cardinal): TExternalTriggerWrapper;
1004   var index: integer;
1005      aTransaction: ITransaction;
# Line 1043 | Line 1021
1021    end;
1022   end;
1023  
1046 function TFBUdrPlugin.GetCharSetID: integer;
1047 begin
1048  Result := FAttachment.GetCharSetID;
1049 end;
1050
1024   end.
1025  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines