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 56 by tony, Mon Mar 6 10:20:02 2017 UTC vs.
Revision 66 by tony, Wed Aug 23 08:23:42 2017 UTC

# Line 181 | Line 181 | type
181      FCharacterSetSize: integer;
182      FAutoFieldSize: boolean;
183      FCodePage: TSystemCodePage;
184 +    FDataSize: integer;
185    protected
186      procedure Bind(Binding: Boolean); override;
187      function GetDataSize: Integer; override;
# Line 790 | Line 791 | type
791      FCharacterSetSize: integer;
792      FCodePage: TSystemCodePage;
793      FRelationName: string;
794 +    FDataSize: integer;
795    published
796      property CharacterSetName: RawByteString read FCharacterSetName write FCharacterSetName;
797      property CharacterSetSize: integer read FCharacterSetSize write FCharacterSetSize;
798      property CodePage: TSystemCodePage read FCodePage write FCodePage;
799 +    property DataSize: integer read FDataSize write FDataSize;
800      property RelationName: string read FRelationName write FRelationName;
801      property ArrayDimensions: integer read FArrayDimensions write FArrayDimensions;
802      property ArrayBounds: TArrayBounds read FArrayBounds write FArrayBounds;
# Line 1089 | Line 1092 | procedure TIBMemoField.SetAsString(const
1092   var s: RawByteString;
1093   begin
1094    s := AValue;
1095 <  if StringCodePage(Value) <> CodePage then
1095 >  if StringCodePage(s) <> CodePage then
1096      SetCodePage(s,CodePage,CodePage<>CP_NONE);
1097    inherited SetAsString(s);
1098   end;
# Line 1141 | Line 1144 | begin
1144      IBFieldDef := FieldDef as TIBFieldDef;
1145      CharacterSetSize := IBFieldDef.CharacterSetSize;
1146      CharacterSetName := IBFieldDef.CharacterSetName;
1147 +    FDataSize := IBFieldDef.DataSize + 1;
1148      if AutoFieldSize then
1149        Size := IBFieldDef.Size;
1150      CodePage := IBFieldDef.CodePage;
# Line 1149 | Line 1153 | end;
1153  
1154   function TIBStringField.GetDataSize: Integer;
1155   begin
1156 <  Result := Size * CharacterSetSize + 1;
1156 >  Result := FDataSize;
1157   end;
1158  
1159   constructor TIBStringField.Create(aOwner: TComponent);
# Line 1208 | Line 1212 | var
1212    s: RawByteString;
1213   begin
1214    Buffer := nil;
1215 <  IBAlloc(Buffer, 0, Size + 1);
1215 >  IBAlloc(Buffer, 0, DataSize);
1216    try
1217      s := Value;
1218      if StringCodePage(s) <> CodePage then
1219        SetCodePage(s,CodePage,CodePage<>CP_NONE);
1220 <    StrLCopy(Buffer, PChar(s), Size);
1220 >    StrLCopy(Buffer, PChar(s), DataSize-1);
1221      if Transliterate then
1222        DataSet.Translate(Buffer, Buffer, True);
1223      SetData(Buffer);
# Line 3671 | Line 3675 | const
3675   var
3676    FieldType: TFieldType;
3677    FieldSize: Word;
3678 +  FieldDataSize: integer;
3679    charSetID: short;
3680    CharSetSize: integer;
3681    CharSetName: RawByteString;
# Line 3807 | Line 3812 | begin
3812          FieldName := getSQLName;
3813          FAliasNameList[i] := DBAliasName;
3814          FieldSize := 0;
3815 +        FieldDataSize := 0;
3816          FieldPrecision := 0;
3817          FieldNullable := IsNullable;
3818          CharSetSize := 0;
# Line 3819 | Line 3825 | begin
3825             their values }
3826            SQL_VARYING, SQL_TEXT:
3827            begin
3828 <            FirebirdAPI.CharSetWidth(getCharSetID,CharSetSize);
3829 <            CharSetName := FirebirdAPI.GetCharsetName(getCharSetID);
3830 <            FirebirdAPI.CharSetID2CodePage(getCharSetID,FieldCodePage);
3831 <            FieldSize := GetSize div CharSetSize;
3828 >            if not Database.Attachment.CharSetWidth(getCharSetID,CharSetSize) then
3829 >              CharSetSize := 1;
3830 >            CharSetName := Database.Attachment.GetCharsetName(getCharSetID);
3831 >            Database.Attachment.CharSetID2CodePage(getCharSetID,FieldCodePage);
3832 >            FieldDataSize := GetSize;
3833 >            FieldSize := FieldDataSize div CharSetSize;
3834              FieldType := ftString;
3835            end;
3836            { All Doubles/Floats should be cast to doubles }
# Line 3836 | Line 3844 | begin
3844                FieldType := ftBCD;
3845                FieldPrecision := 4;
3846                FieldSize := -getScale;
3847 +              FieldDataSize := FieldSize;
3848              end;
3849            end;
3850            SQL_LONG:
# Line 3860 | Line 3869 | begin
3869                FieldPrecision := 9;
3870                FieldSize := -getScale;
3871              end;
3872 +            FieldDataSize := FieldSize;
3873            end;
3874  
3875            SQL_INT64:
# Line 3873 | Line 3883 | begin
3883                FieldSize := -getScale;
3884              end
3885              else
3886 <              FieldType := ftFloat
3886 >              FieldType := ftFloat;
3887 >            FieldDataSize := FieldSize;
3888            end;
3889            SQL_TIMESTAMP: FieldType := ftDateTime;
3890            SQL_TYPE_TIME: FieldType := ftTime;
# Line 3883 | Line 3894 | begin
3894              FieldSize := sizeof (TISC_QUAD);
3895              if (getSubtype = 1) then
3896              begin
3897 <              FirebirdAPI.CharSetWidth(getCharSetID,CharSetSize);
3898 <              CharSetName := FirebirdAPI.GetCharsetName(getCharSetID);
3899 <              FirebirdAPI.CharSetID2CodePage(getCharSetID,FieldCodePage);
3897 >              if not Database.Attachment.CharSetWidth(getCharSetID,CharSetSize) then
3898 >                CharSetSize := 1;
3899 >              CharSetName := Database.Attachment.GetCharsetName(getCharSetID);
3900 >              Database.Attachment.CharSetID2CodePage(getCharSetID,FieldCodePage);
3901                FieldType := ftMemo;
3902              end
3903              else
3904                FieldType := ftBlob;
3905 +            FieldDataSize := FieldSize;
3906            end;
3907            SQL_ARRAY:
3908            begin
3909              FieldSize := sizeof (TISC_QUAD);
3910 +            FieldDataSize := FieldSize;
3911              FieldType := ftArray;
3912              ArrayMetaData := GetArrayMetaData;
3913              if ArrayMetaData <> nil then
# Line 3917 | Line 3931 | begin
3931              Name := FieldAliasName;
3932              FAliasNameMap[FieldNo-1] := DBAliasName;
3933              Size := FieldSize;
3934 +            DataSize := FieldDataSize;
3935              Precision := FieldPrecision;
3936              Required := not FieldNullable;
3937              RelationName := aRelationName;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines