ViewVC Help
View File | Revision Log | Show Annotations | Download File | View Changeset | Root Listing
root/public/ibx/trunk/runtime/IBCustomDataSet.pas
(Generate patch)

Comparing ibx/trunk/runtime/IBCustomDataSet.pas (file contents):
Revision 57 by tony, Wed Mar 8 11:20:46 2017 UTC vs.
Revision 80 by tony, Mon Jan 1 11:31:07 2018 UTC

# Line 74 | Line 74 | type
74      procedure SetDataSet(ADataSet: TIBCustomDataSet); virtual; abstract;
75      procedure Apply(UpdateKind: TUpdateKind; buff: PChar); virtual; abstract;
76      function GetSQL(UpdateKind: TUpdateKind): TStrings; virtual; abstract;
77 <    procedure InternalSetParams(Query: TIBSQL; buff: PChar);
77 >    procedure InternalSetParams(Params: ISQLParams; buff: PChar); overload;
78 >    procedure InternalSetParams(Query: TIBSQL; buff: PChar); overload;
79      property DataSet: TIBCustomDataSet read GetDataSet write SetDataSet;
80    public
81      constructor Create(AOwner: TComponent); override;
# Line 181 | Line 182 | type
182      FCharacterSetSize: integer;
183      FAutoFieldSize: boolean;
184      FCodePage: TSystemCodePage;
185 +    FDataSize: integer;
186    protected
187      procedure Bind(Binding: Boolean); override;
188      function GetDataSize: Integer; override;
# Line 434 | Line 436 | type
436      procedure SetDatabase(Value: TIBDatabase);
437      procedure SetDeleteSQL(Value: TStrings);
438      procedure SetInsertSQL(Value: TStrings);
439 <    procedure SetInternalSQLParams(Qry: TIBSQL; Buffer: Pointer);
439 >    procedure SetInternalSQLParams(Params: ISQLParams; Buffer: Pointer);
440      procedure SetRefreshSQL(Value: TStrings);
441      procedure SetSelectSQL(Value: TStrings);
442      procedure SetModifySQL(Value: TStrings);
# Line 790 | Line 792 | type
792      FCharacterSetSize: integer;
793      FCodePage: TSystemCodePage;
794      FRelationName: string;
795 +    FDataSize: integer;
796    published
797      property CharacterSetName: RawByteString read FCharacterSetName write FCharacterSetName;
798      property CharacterSetSize: integer read FCharacterSetSize write FCharacterSetSize;
799      property CodePage: TSystemCodePage read FCodePage write FCodePage;
800 +    property DataSize: integer read FDataSize write FDataSize;
801      property RelationName: string read FRelationName write FRelationName;
802      property ArrayDimensions: integer read FArrayDimensions write FArrayDimensions;
803      property ArrayBounds: TArrayBounds read FArrayBounds write FArrayBounds;
# Line 1141 | Line 1145 | begin
1145      IBFieldDef := FieldDef as TIBFieldDef;
1146      CharacterSetSize := IBFieldDef.CharacterSetSize;
1147      CharacterSetName := IBFieldDef.CharacterSetName;
1148 +    FDataSize := IBFieldDef.DataSize + 1;
1149      if AutoFieldSize then
1150        Size := IBFieldDef.Size;
1151      CodePage := IBFieldDef.CodePage;
# Line 1149 | Line 1154 | end;
1154  
1155   function TIBStringField.GetDataSize: Integer;
1156   begin
1157 <  Result := Size * CharacterSetSize + 1;
1157 >  Result := FDataSize;
1158   end;
1159  
1160   constructor TIBStringField.Create(aOwner: TComponent);
# Line 1208 | Line 1213 | var
1213    s: RawByteString;
1214   begin
1215    Buffer := nil;
1216 <  IBAlloc(Buffer, 0, Size + 1);
1216 >  IBAlloc(Buffer, 0, DataSize);
1217    try
1218      s := Value;
1219      if StringCodePage(s) <> CodePage then
1220        SetCodePage(s,CodePage,CodePage<>CP_NONE);
1221 <    StrLCopy(Buffer, PChar(s), Size);
1221 >    StrLCopy(Buffer, PChar(s), DataSize-1);
1222      if Transliterate then
1223        DataSet.Translate(Buffer, Buffer, True);
1224      SetData(Buffer);
# Line 2198 | Line 2203 | begin
2203      FUpdateObject.Apply(ukDelete,Buff)
2204    else
2205    begin
2206 <    SetInternalSQLParams(FQDelete, Buff);
2206 >    SetInternalSQLParams(FQDelete.Params, Buff);
2207      FQDelete.ExecQuery;
2208    end;
2209    with PRecordData(Buff)^ do
# Line 2347 | Line 2352 | begin
2352        FUpdateObject.Apply(ukModify,Buff);
2353    end
2354    else begin
2355 <    SetInternalSQLParams(Qry, Buff);
2355 >    SetInternalSQLParams(Qry.Params, Buff);
2356      Qry.ExecQuery;
2357    end;
2358    PRecordData(Buff)^.rdUpdateStatus := usUnmodified;
# Line 2381 | Line 2386 | begin
2386          end
2387          else
2388            Qry := FQRefresh;
2389 <        SetInternalSQLParams(Qry, Buff);
2389 >        SetInternalSQLParams(Qry.Params, Buff);
2390          Qry.ExecQuery;
2391          try
2392            if (Qry.SQLStatementType = SQLExecProcedure) or Qry.Next then
# Line 2593 | Line 2598 | begin
2598    if (FBase.Database <> Value) then
2599    begin
2600      CheckDatasetClosed;
2601 +    InternalUnPrepare;
2602      FBase.Database := Value;
2603      FQDelete.Database := Value;
2604      FQInsert.Database := Value;
# Line 2620 | Line 2626 | begin
2626    end;
2627   end;
2628  
2629 < procedure TIBCustomDataSet.SetInternalSQLParams(Qry: TIBSQL; Buffer: Pointer);
2629 > procedure TIBCustomDataSet.SetInternalSQLParams(Params: ISQLParams; Buffer: Pointer);
2630   var
2631    i, j: Integer;
2632    cr, data: PChar;
# Line 2636 | Line 2642 | begin
2642      InternalPrepare;
2643    OldBuffer := nil;
2644    try
2645 <    for i := 0 to Qry.Params.GetCount - 1 do
2645 >    for i := 0 to Params.GetCount - 1 do
2646      begin
2647 <      Param := Qry.Params[i];
2647 >      Param := Params[i];
2648        fn := Param.Name;
2649        if (Pos('OLD_', fn) = 1) then {mbcs ok}
2650        begin
# Line 3671 | Line 3677 | const
3677   var
3678    FieldType: TFieldType;
3679    FieldSize: Word;
3680 +  FieldDataSize: integer;
3681    charSetID: short;
3682    CharSetSize: integer;
3683    CharSetName: RawByteString;
# Line 3807 | Line 3814 | begin
3814          FieldName := getSQLName;
3815          FAliasNameList[i] := DBAliasName;
3816          FieldSize := 0;
3817 +        FieldDataSize := GetSize;
3818          FieldPrecision := 0;
3819          FieldNullable := IsNullable;
3820          CharSetSize := 0;
# Line 3819 | Line 3827 | begin
3827             their values }
3828            SQL_VARYING, SQL_TEXT:
3829            begin
3830 <            FirebirdAPI.CharSetWidth(getCharSetID,CharSetSize);
3831 <            CharSetName := FirebirdAPI.GetCharsetName(getCharSetID);
3832 <            FirebirdAPI.CharSetID2CodePage(getCharSetID,FieldCodePage);
3833 <            FieldSize := GetSize div CharSetSize;
3830 >            if not Database.Attachment.CharSetWidth(getCharSetID,CharSetSize) then
3831 >              CharSetSize := 1;
3832 >            CharSetName := Database.Attachment.GetCharsetName(getCharSetID);
3833 >            Database.Attachment.CharSetID2CodePage(getCharSetID,FieldCodePage);
3834 >            FieldSize := FieldDataSize div CharSetSize;
3835              FieldType := ftString;
3836            end;
3837            { All Doubles/Floats should be cast to doubles }
# Line 3873 | Line 3882 | begin
3882                FieldSize := -getScale;
3883              end
3884              else
3885 <              FieldType := ftFloat
3885 >              FieldType := ftFloat;
3886            end;
3887            SQL_TIMESTAMP: FieldType := ftDateTime;
3888            SQL_TYPE_TIME: FieldType := ftTime;
# Line 3883 | Line 3892 | begin
3892              FieldSize := sizeof (TISC_QUAD);
3893              if (getSubtype = 1) then
3894              begin
3895 <              FirebirdAPI.CharSetWidth(getCharSetID,CharSetSize);
3896 <              CharSetName := FirebirdAPI.GetCharsetName(getCharSetID);
3897 <              FirebirdAPI.CharSetID2CodePage(getCharSetID,FieldCodePage);
3895 >              if not Database.Attachment.CharSetWidth(getCharSetID,CharSetSize) then
3896 >                CharSetSize := 1;
3897 >              CharSetName := Database.Attachment.GetCharsetName(getCharSetID);
3898 >              Database.Attachment.CharSetID2CodePage(getCharSetID,FieldCodePage);
3899                FieldType := ftMemo;
3900              end
3901              else
# Line 3917 | Line 3927 | begin
3927              Name := FieldAliasName;
3928              FAliasNameMap[FieldNo-1] := DBAliasName;
3929              Size := FieldSize;
3930 +            DataSize := FieldDataSize;
3931              Precision := FieldPrecision;
3932              Required := not FieldNullable;
3933              RelationName := aRelationName;
# Line 4672 | Line 4683 | begin
4683    Transaction.StartTransaction;
4684   end;
4685  
4686 < function TIBCustomDataSet.PSGetTableName: string;
4686 > function TIBCustomDataSet.PsGetTableName: string;
4687   begin
4688   //  if not FInternalPrepared then
4689   //    InternalPrepare;
# Line 4813 | Line 4824 | begin
4824    inherited Destroy;
4825   end;
4826  
4827 < procedure TIBDataSetUpdateObject.SetRefreshSQL(Value: TStrings);
4827 > procedure TIBDataSetUpdateObject.SetRefreshSQL(value: TStrings);
4828   begin
4829    FRefreshSQL.Assign(Value);
4830   end;
4831  
4832 < procedure TIBDataSetUpdateObject.InternalSetParams(Query: TIBSQL; buff: PChar);
4832 > procedure TIBDataSetUpdateObject.InternalSetParams(Params: ISQLParams;
4833 >  buff: PChar);
4834   begin
4835    if not Assigned(DataSet) then Exit;
4836 <  DataSet.SetInternalSQLParams(Query, buff);
4836 >  DataSet.SetInternalSQLParams(Params, buff);
4837 > end;
4838 >
4839 > procedure TIBDataSetUpdateObject.InternalSetParams(Query: TIBSQL; buff: PChar);
4840 > begin
4841 >  InternalSetParams(Query.Params,buff);
4842   end;
4843  
4844   function TIBDSBlobStream.GetSize: Int64;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines