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

Comparing ibx/trunk/fbintf/client/2.5/FB25Statement.pas (file contents):
Revision 209 by tony, Wed Mar 14 12:48:51 2018 UTC vs.
Revision 309 by tony, Tue Jul 21 08:00:42 2020 UTC

# Line 121 | Line 121 | type
121    TIBXSQLVAR = class(TSQLVarData)
122    private
123      FStatement: TFB25Statement;
124 +    FFirebird25ClientAPI: TFB25ClientAPI;
125      FBlob: IBlob;             {Cache references}
126      FArray: IArray;
127      FNullIndicator: short;
# Line 138 | Line 139 | type
139      function GetScale: integer; override;
140      function GetCharSetID: cardinal; override;
141      function GetCodePage: TSystemCodePage; override;
142 +    function GetCharSetWidth: integer; override;
143      function GetIsNull: Boolean;   override;
144      function GetIsNullable: boolean; override;
145      function GetSQLData: PByte;  override;
# Line 177 | Line 179 | type
179      function GetXSQLDA: PXSQLDA;
180    protected
181      FStatement: TFB25Statement;
182 +    FFirebird25ClientAPI: TFB25ClientAPI;
183      function GetTransactionSeqNo: integer; override;
184      procedure FreeXSQLDA;
185      function GetStatement: IStatement; override;
# Line 241 | Line 244 | type
244    private
245      FDBHandle: TISC_DB_HANDLE;
246      FHandle: TISC_STMT_HANDLE;
247 +    FFirebird25ClientAPI: TFB25ClientAPI;
248      FSQLParams: TIBXINPUTSQLDA;
249      FSQLRecord: TIBXOUTPUTSQLDA;
250      FCursor: AnsiString;               { Cursor name...}
# Line 252 | Line 256 | type
256      procedure InternalPrepare; override;
257      function InternalExecute(aTransaction: ITransaction): IResults; override;
258      function InternalOpenCursor(aTransaction: ITransaction): IResultSet; override;
259 +    procedure ProcessSQL(sql: AnsiString; GenerateParamNames: boolean; var processedSQL: AnsiString); override;
260      procedure FreeHandle; override;
261      procedure InternalClose(Force: boolean); override;
262    public
263      constructor Create(Attachment: TFB25Attachment; Transaction: ITransaction;
264        sql: AnsiString; aSQLDialect: integer);
265      constructor CreateWithParameterNames(Attachment: TFB25Attachment;
266 <      Transaction: ITransaction; sql: AnsiString; aSQLDialect: integer; GenerateParamNames: boolean);
266 >      Transaction: ITransaction; sql: AnsiString; aSQLDialect: integer; GenerateParamNames: boolean;
267 >      CaseSensitiveParams: boolean=false);
268      destructor Destroy; override;
269      function FetchNext: boolean;
270  
# Line 350 | Line 356 | begin
356       CharSetID2CodePage(GetCharSetID,result);
357   end;
358  
359 + function TIBXSQLVAR.GetCharSetWidth: integer;
360 + begin
361 +  result := 1;
362 +  with Statement.GetAttachment DO
363 +    CharSetWidth(GetCharSetID,result);
364 + end;
365 +
366   function TIBXSQLVAR.GetIsNull: Boolean;
367   begin
368    result := IsNullable and (FNullIndicator = -1);
# Line 441 | Line 454 | procedure TIBXSQLVAR.Initialize;
454   begin
455    inherited Initialize;
456    FOwnsSQLData := true;
457 <  with FirebirdClientAPI, FXSQLVar^ do
457 >  with FFirebird25ClientAPI, FXSQLVar^ do
458    begin
459      case sqltype and (not 1) of
460        SQL_TEXT, SQL_TYPE_DATE, SQL_TYPE_TIME, SQL_TIMESTAMP,
# Line 526 | Line 539 | begin
539    if not FOwnsSQLData then
540      FXSQLVAR^.sqldata := nil;
541    FXSQLVAR^.sqllen := len;
542 <  with FirebirdClientAPI do
542 >  with FFirebird25ClientAPI do
543      IBAlloc(FXSQLVAR^.sqldata, 0, FXSQLVAR^.sqllen);
544    FOwnsSQLData := true;
545    Changed;
# Line 558 | Line 571 | constructor TIBXSQLVAR.Create(aParent: T
571   begin
572    inherited Create(aParent,aIndex);
573    FStatement := aParent.Statement;
574 +  FFirebird25ClientAPI := aParent.FFirebird25ClientAPI;
575   end;
576  
577   procedure TIBXSQLVAR.FreeSQLData;
# Line 628 | Line 642 | procedure TIBXINPUTSQLDA.Bind;
642   begin
643    if Count = 0 then
644      Count := 1;
645 <  with Firebird25ClientAPI do
645 >  with FFirebird25ClientAPI do
646    begin
647      if (FXSQLDA <> nil) then
648         if isc_dsql_describe_bind(StatusVector, @(FStatement.Handle), FStatement.SQLDialect,
# Line 660 | Line 674 | procedure TIBXOUTPUTSQLDA.Bind;
674   begin
675    { Allocate an initial output descriptor (with one column) }
676    Count := 1;
677 <  with Firebird25ClientAPI do
677 >  with FFirebird25ClientAPI do
678    begin
679      { Using isc_dsql_describe, get the right size for the columns... }
680      if isc_dsql_describe(StatusVector, @(FStatement.Handle), FStatement.SQLDialect, FXSQLDA) > 0 then
# Line 695 | Line 709 | begin
709      len := sqllen;
710      if not IsNull and ((sqltype and (not 1)) = SQL_VARYING) then
711      begin
712 <      with FirebirdClientAPI do
712 >      with FFirebird25ClientAPI do
713          len := DecodeInteger(data,2);
714        Inc(data,2);
715      end;
# Line 712 | Line 726 | constructor TIBXSQLDA.Create(aStatement:
726   begin
727    inherited Create;
728    FStatement := aStatement;
729 +  FFirebird25ClientAPI := aStatement.FFirebird25ClientAPI;
730    FSize := 0;
731   //  writeln('Creating ',ClassName);
732   end;
# Line 798 | Line 813 | begin
813        OldSize := 0;
814      if Count > FSize then
815      begin
816 <      Firebird25ClientAPI.IBAlloc(FXSQLDA, OldSize, XSQLDA_LENGTH(Count));
816 >      FFirebird25ClientAPI.IBAlloc(FXSQLDA, OldSize, XSQLDA_LENGTH(Count));
817        SetLength(FColumnList, FCount);
818        FXSQLDA^.version := SQLDA_VERSION1;
819        p := @FXSQLDA^.sqlvar[0];
# Line 896 | Line 911 | end;
911   procedure TFB25Statement.GetDsqlInfo(info_request: byte; buffer: ISQLInfoResults
912    );
913   begin
914 <  with Firebird25ClientAPI, buffer as TSQLInfoResultsBuffer do
914 >  with FFirebird25ClientAPI, buffer as TSQLInfoResultsBuffer do
915    if isc_dsql_sql_info(StatusVector, @(FHandle), 1, @info_request,
916                       GetBufSize, Buffer) > 0 then
917      IBDatabaseError;
# Line 913 | Line 928 | begin
928      IBError(ibxeEmptyQuery, [nil]);
929    try
930      CheckTransaction(FTransactionIntf);
931 <    with Firebird25ClientAPI do
931 >    with FFirebird25ClientAPI do
932      begin
933        Call(isc_dsql_alloc_statement2(StatusVector, @(FDBHandle),
934                                        @FHandle), True);
# Line 921 | Line 936 | begin
936        if FHasParamNames then
937        begin
938          if FProcessedSQL = '' then
939 <          FSQLParams.PreprocessSQL(FSQL,FGenerateParamNames,FProcessedSQL);
939 >          ProcessSQL(FSQL,FGenerateParamNames,FProcessedSQL);
940          Call(isc_dsql_prepare(StatusVector, @(TRHandle), @FHandle, 0,
941                   PAnsiChar(FProcessedSQL), FSQLDialect, nil), True);
942        end
# Line 1007 | Line 1022 | begin
1022  
1023    try
1024      TRHandle := (aTransaction as TFB25Transaction).Handle;
1025 <    with Firebird25ClientAPI do
1025 >    with FFirebird25ClientAPI do
1026      begin
1027        if FCollectStatistics then
1028          GetPerfCounters(FBeforeStats);
# Line 1068 | Line 1083 | begin
1083    if (FSQLParams.FTransactionSeqNo < (FTransactionIntf as TFB25transaction).TransactionSeqNo) then
1084      IBError(ibxeInterfaceOutofDate,[nil]);
1085  
1086 < with Firebird25ClientAPI do
1086 > with FFirebird25ClientAPI do
1087   begin
1088     if FCollectStatistics then
1089       GetPerfCounters(FBeforeStats);
# Line 1107 | Line 1122 | begin
1122   Inc(FChangeSeqNo);
1123   end;
1124  
1125 + procedure TFB25Statement.ProcessSQL(sql: AnsiString; GenerateParamNames: boolean;
1126 +  var processedSQL: AnsiString);
1127 + begin
1128 +  FSQLParams.PreprocessSQL(sql,GenerateParamNames, processedSQL);
1129 + end;
1130 +
1131   procedure TFB25Statement.FreeHandle;
1132   var
1133    isc_res: ISC_STATUS;
# Line 1115 | Line 1136 | begin
1136    ReleaseInterfaces;
1137    try
1138      if FHandle <> nil then
1139 <    with Firebird25ClientAPI do
1139 >    with FFirebird25ClientAPI do
1140      begin
1141        isc_res :=
1142          Call(isc_dsql_free_statement(StatusVector, @FHandle, DSQL_drop), False);
# Line 1135 | Line 1156 | var
1156   begin
1157    if (FHandle <> nil) and (SQLStatementType = SQLSelect) and FOpen then
1158    try
1159 <    with Firebird25ClientAPI do
1159 >    with FFirebird25ClientAPI do
1160      begin
1161        isc_res := Call(
1162                     isc_dsql_free_statement(StatusVector, @FHandle, DSQL_close),
# Line 1160 | Line 1181 | constructor TFB25Statement.Create(Attach
1181   begin
1182    inherited Create(Attachment,Transaction,sql,aSQLDialect);
1183    FDBHandle := Attachment.Handle;
1184 +  FFirebird25ClientAPI := Attachment.Firebird25ClientAPI;
1185 +  OnDatabaseError := FFirebird25ClientAPI.IBDataBaseError;
1186    FSQLParams := TIBXINPUTSQLDA.Create(self);
1187    FSQLRecord := TIBXOUTPUTSQLDA.Create(self);
1188    InternalPrepare;
1189   end;
1190  
1191 < constructor TFB25Statement.CreateWithParameterNames(Attachment: TFB25Attachment;
1192 <  Transaction: ITransaction; sql: AnsiString; aSQLDialect: integer;
1193 <  GenerateParamNames: boolean);
1191 > constructor TFB25Statement.CreateWithParameterNames(
1192 >  Attachment: TFB25Attachment; Transaction: ITransaction; sql: AnsiString;
1193 >  aSQLDialect: integer; GenerateParamNames: boolean;
1194 >  CaseSensitiveParams: boolean);
1195   begin
1196    inherited CreateWithParameterNames(Attachment,Transaction,sql,aSQLDialect,GenerateParamNames);
1197    FDBHandle := Attachment.Handle;
1198 +  FFirebird25ClientAPI := Attachment.Firebird25ClientAPI;
1199 +  OnDatabaseError := FFirebird25ClientAPI.IBDataBaseError;
1200    FSQLParams := TIBXINPUTSQLDA.Create(self);
1201 +  FSQLParams.CaseSensitiveParams := CaseSensitiveParams;
1202    FSQLRecord := TIBXOUTPUTSQLDA.Create(self);
1203    InternalPrepare;
1204   end;
# Line 1193 | Line 1220 | begin
1220    if FEOF then
1221      IBError(ibxeEOF,[nil]);
1222  
1223 <  with Firebird25ClientAPI do
1223 >  with FFirebird25ClientAPI do
1224    begin
1225      { Go to the next record... }
1226      fetch_res :=
# Line 1256 | Line 1283 | begin
1283      result := ''
1284    else
1285    begin
1286 <    RB := TSQLInfoResultsBuffer.Create(4*4096);
1286 >    RB := TSQLInfoResultsBuffer.Create(FFirebird25ClientAPI,4*4096);
1287      GetDsqlInfo(isc_info_sql_get_plan,RB);
1288       if RB.Count > 0 then
1289       Result := RB[0].GetAsString;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines