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

Comparing ibx/trunk/fbintf/client/3.0/FB30Statement.pas (file contents):
Revision 111 by tony, Thu Jan 18 14:37:53 2018 UTC vs.
Revision 309 by tony, Tue Jul 21 08:00:42 2020 UTC

# Line 87 | Line 87 | type
87    TIBXSQLVAR = class(TSQLVarData)
88    private
89      FStatement: TFB30Statement;
90 +    FFirebird30ClientAPI: TFB30ClientAPI;
91      FBlob: IBlob;             {Cache references}
92      FArray: IArray;
93      FNullIndicator: short;
# Line 116 | Line 117 | type
117       function GetScale: integer; override;
118       function GetCharSetID: cardinal; override;
119       function GetCodePage: TSystemCodePage; override;
120 +     function GetCharSetWidth: integer; override;
121       function GetIsNull: Boolean;   override;
122       function GetIsNullable: boolean; override;
123       function GetSQLData: PByte;  override;
# Line 148 | Line 150 | type
150      FSize: Integer;  {Number of TIBXSQLVARs in column list}
151      FMetaData: Firebird.IMessageMetadata;
152      FTransactionSeqNo: integer;
153 <  protected
153 > protected
154      FStatement: TFB30Statement;
155 +    FFirebird30ClientAPI: TFB30ClientAPI;
156      function GetTransactionSeqNo: integer; override;
157      procedure FreeXSQLDA; virtual;
158      function GetStatement: IStatement; override;
# Line 236 | Line 239 | type
239    TFB30Statement = class(TFBStatement,IStatement)
240    private
241      FStatementIntf: Firebird.IStatement;
242 +    FFirebird30ClientAPI: TFB30ClientAPI;
243      FSQLParams: TIBXINPUTSQLDA;
244      FSQLRecord: TIBXOUTPUTSQLDA;
245      FResultSet: Firebird.IResultSet;
# Line 246 | Line 250 | type
250      procedure InternalPrepare; override;
251      function InternalExecute(aTransaction: ITransaction): IResults; override;
252      function InternalOpenCursor(aTransaction: ITransaction): IResultSet; override;
253 +    procedure ProcessSQL(sql: AnsiString; GenerateParamNames: boolean; var processedSQL: AnsiString); override;
254      procedure FreeHandle; override;
255      procedure InternalClose(Force: boolean); override;
256    public
257      constructor Create(Attachment: TFB30Attachment; Transaction: ITransaction;
258        sql: AnsiString; aSQLDialect: integer);
259      constructor CreateWithParameterNames(Attachment: TFB30Attachment; Transaction: ITransaction;
260 <      sql: AnsiString;  aSQLDialect: integer; GenerateParamNames: boolean =false);
260 >      sql: AnsiString;  aSQLDialect: integer; GenerateParamNames: boolean =false;
261 >      CaseSensitiveParams: boolean=false);
262      destructor Destroy; override;
263      function FetchNext: boolean;
264      property StatementIntf: Firebird.IStatement read FStatementIntf;
# Line 296 | Line 302 | end;
302  
303   function TIBXSQLVAR.GetAliasName: AnsiString;
304   begin
305 <  with Firebird30ClientAPI do
305 >  with FFirebird30ClientAPI do
306    begin
307      result := strpas(TIBXSQLDA(Parent).MetaData.getAlias(StatusIntf,Index));
308      Check4DataBaseError;
# Line 310 | Line 316 | end;
316  
317   function TIBXSQLVAR.GetOwnerName: AnsiString;
318   begin
319 <  with Firebird30ClientAPI do
319 >  with FFirebird30ClientAPI do
320    begin
321      result := strpas(TIBXSQLDA(Parent).MetaData.getOwner(StatusIntf,Index));
322      Check4DataBaseError;
# Line 354 | Line 360 | begin
360       CharSetID2CodePage(GetCharSetID,result);
361   end;
362  
363 + function TIBXSQLVAR.GetCharSetWidth: integer;
364 + begin
365 +  result := 1;
366 +  with Statement.GetAttachment DO
367 +    CharSetWidth(GetCharSetID,result);
368 + end;
369 +
370   function TIBXSQLVAR.GetIsNull: Boolean;
371   begin
372    Result := IsNullable and (FSQLNullIndicator^ = -1);
# Line 447 | Line 460 | begin
460    if not FOwnsSQLData then
461      FSQLData := nil;
462    FDataLength := len;
463 <  with Firebird30ClientAPI do
463 >  with FFirebird30ClientAPI do
464      IBAlloc(FSQLData, 0, FDataLength);
465    FOwnsSQLData := true;
466    Changed;
# Line 469 | Line 482 | constructor TIBXSQLVAR.Create(aParent: T
482   begin
483    inherited Create(aParent,aIndex);
484    FStatement := aParent.Statement;
485 +  FFirebird30ClientAPI := aParent.FFirebird30ClientAPI;
486   end;
487  
488   procedure TIBXSQLVAR.RowChange;
# Line 629 | Line 643 | var Builder: Firebird.IMetadataBuilder;
643      i: integer;
644   begin
645    if FCurMetaData = nil then
646 <  with Firebird30ClientAPI do
646 >  with FFirebird30ClientAPI do
647    begin
648      Builder := inherited MetaData.getBuilder(StatusIntf);
649      Check4DataBaseError;
# Line 662 | Line 676 | begin
676    BuildMetadata;
677  
678    if FMsgLength = 0 then
679 <  with Firebird30ClientAPI do
679 >  with FFirebird30ClientAPI do
680    begin
681      FMsgLength := FCurMetaData.getMessageLength(StatusIntf);
682      Check4DataBaseError;
# Line 712 | Line 726 | procedure TIBXINPUTSQLDA.Bind(aMetaData:
726   var i: integer;
727   begin
728    FMetaData := aMetaData;
729 <  with Firebird30ClientAPI do
729 >  with FFirebird30ClientAPI do
730    begin
731      Count := metadata.getCount(StatusIntf);
732      Check4DataBaseError;
# Line 790 | Line 804 | procedure TIBXOUTPUTSQLDA.Bind(aMetaData
804   var i: integer;
805   begin
806    FMetaData := aMetaData;
807 <  with Firebird30ClientAPI do
807 >  with FFirebird30ClientAPI do
808    begin
809      Count := metadata.getCount(StatusIntf);
810      Check4DataBaseError;
# Line 850 | Line 864 | begin
864      len := FDataLength;
865      if not IsNull and (FSQLType = SQL_VARYING) then
866      begin
867 <      with Firebird30ClientAPI do
867 >      with FFirebird30ClientAPI do
868          len := DecodeInteger(data,2);
869        Inc(Data,2);
870      end;
# Line 867 | Line 881 | constructor TIBXSQLDA.Create(aStatement:
881   begin
882    inherited Create;
883    FStatement := aStatement;
884 +  FFirebird30ClientAPI := aStatement.FFirebird30ClientAPI;
885    FSize := 0;
886   //  writeln('Creating ',ClassName);
887   end;
# Line 983 | Line 998 | end;
998   procedure TFB30Statement.GetDSQLInfo(info_request: byte; buffer: ISQLInfoResults
999    );
1000   begin
1001 <  with Firebird30ClientAPI, buffer as TSQLInfoResultsBuffer do
1001 >  with FFirebird30ClientAPI, buffer as TSQLInfoResultsBuffer do
1002    begin
1003      StatementIntf.getInfo(StatusIntf,1,BytePtr(@info_request),
1004                       GetBufSize, BytePtr(Buffer));
# Line 999 | Line 1014 | begin
1014      IBError(ibxeEmptyQuery, [nil]);
1015    try
1016      CheckTransaction(FTransactionIntf);
1017 <    with Firebird30ClientAPI do
1017 >    with FFirebird30ClientAPI do
1018      begin
1019        if FHasParamNames then
1020        begin
1021          if FProcessedSQL = '' then
1022 <          FSQLParams.PreprocessSQL(FSQL,FGenerateParamNames,FProcessedSQL);
1022 >          ProcessSQL(FSQL,FGenerateParamNames,FProcessedSQL);
1023          FStatementIntf := (GetAttachment as TFB30Attachment).AttachmentIntf.prepare(StatusIntf,
1024                              (FTransactionIntf as TFB30Transaction).TransactionIntf,
1025                              Length(FProcessedSQL),
# Line 1096 | Line 1111 | begin
1111      IBError(ibxeInterfaceOutofDate,[nil]);
1112  
1113    try
1114 <    with Firebird30ClientAPI do
1114 >    with FFirebird30ClientAPI do
1115      begin
1116        if FCollectStatistics then
1117        begin
# Line 1167 | Line 1182 | begin
1182    if (FSQLParams.FTransactionSeqNo < (FTransactionIntf as TFB30transaction).TransactionSeqNo) then
1183      IBError(ibxeInterfaceOutofDate,[nil]);
1184  
1185 < with Firebird30ClientAPI do
1185 > with FFirebird30ClientAPI do
1186   begin
1187     if FCollectStatistics then
1188     begin
# Line 1207 | Line 1222 | begin
1222   Inc(FChangeSeqNo);
1223   end;
1224  
1225 + procedure TFB30Statement.ProcessSQL(sql: AnsiString; GenerateParamNames: boolean;
1226 +  var processedSQL: AnsiString);
1227 + begin
1228 +  FSQLParams.PreprocessSQL(sql,GenerateParamNames,processedSQL);
1229 + end;
1230 +
1231   procedure TFB30Statement.FreeHandle;
1232   begin
1233    Close;
# Line 1223 | Line 1244 | procedure TFB30Statement.InternalClose(F
1244   begin
1245    if (FStatementIntf <> nil) and (SQLStatementType = SQLSelect) and FOpen then
1246    try
1247 <    with Firebird30ClientAPI do
1247 >    with FFirebird30ClientAPI do
1248      begin
1249        if FResultSet <> nil then
1250        begin
# Line 1251 | Line 1272 | constructor TFB30Statement.Create(Attach
1272    Transaction: ITransaction; sql: AnsiString; aSQLDialect: integer);
1273   begin
1274    inherited Create(Attachment,Transaction,sql,aSQLDialect);
1275 +  FFirebird30ClientAPI := Attachment.Firebird30ClientAPI;
1276    FSQLParams := TIBXINPUTSQLDA.Create(self);
1277    FSQLRecord := TIBXOUTPUTSQLDA.Create(self);
1278    InternalPrepare;
# Line 1258 | Line 1280 | end;
1280  
1281   constructor TFB30Statement.CreateWithParameterNames(
1282    Attachment: TFB30Attachment; Transaction: ITransaction; sql: AnsiString;
1283 <  aSQLDialect: integer; GenerateParamNames: boolean);
1283 >  aSQLDialect: integer; GenerateParamNames: boolean;
1284 >  CaseSensitiveParams: boolean);
1285   begin
1286    inherited CreateWithParameterNames(Attachment,Transaction,sql,aSQLDialect,GenerateParamNames);
1287 +  FFirebird30ClientAPI := Attachment.Firebird30ClientAPI;
1288    FSQLParams := TIBXINPUTSQLDA.Create(self);
1289 +  FSQLParams.CaseSensitiveParams := CaseSensitiveParams;
1290    FSQLRecord := TIBXOUTPUTSQLDA.Create(self);
1291    InternalPrepare;
1292   end;
# Line 1282 | Line 1307 | begin
1307    if FEOF then
1308      IBError(ibxeEOF,[nil]);
1309  
1310 <  with Firebird30ClientAPI do
1310 >  with FFirebird30ClientAPI do
1311    begin
1312      { Go to the next record... }
1313      fetchResult := FResultSet.fetchNext(StatusIntf,FSQLRecord.MessageBuffer);
# Line 1307 | Line 1332 | begin
1332        FBOF := false;
1333        result := true;
1334      end;
1335 +    if FCollectStatistics then
1336 +    begin
1337 +      UtilIntf.getPerfCounters(StatusIntf,
1338 +                              (GetAttachment as TFB30Attachment).AttachmentIntf,
1339 +                              ISQL_COUNTERS,@FAfterStats);
1340 +      Check4DataBaseError;
1341 +      FStatisticsAvailable := true;
1342 +    end;
1343    end;
1344    FSQLRecord.RowChange;
1345    SignalActivity;
# Line 1338 | Line 1371 | begin
1371         SQLUpdate, SQLDelete])) then
1372      result := ''
1373    else
1374 <  with Firebird30ClientAPI do
1374 >  with FFirebird30ClientAPI do
1375    begin
1376      Result := FStatementIntf.getPlan(StatusIntf,true);
1377      Check4DataBaseError;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines