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; |
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; |
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; |
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; |
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); |
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); |
1853 |
|
FQModify.FreeHandle; |
1854 |
|
if FQRefresh <> nil then |
1855 |
|
FQRefresh.FreeHandle; |
1856 |
+ |
InternalUnPrepare; |
1857 |
|
if Assigned(FBeforeTransactionEnd) then |
1858 |
|
FBeforeTransactionEnd(Sender); |
1859 |
|
end; |
1967 |
|
pbd: PBlobDataArray; |
1968 |
|
pda: PArrayDataArray; |
1969 |
|
i, j: Integer; |
1970 |
< |
LocalData: PChar; |
1970 |
> |
LocalData: PByte; |
1971 |
|
LocalDate, LocalDouble: Double; |
1972 |
|
LocalInt: Integer; |
1973 |
|
LocalBool: wordBool; |
2034 |
|
SQL_TIMESTAMP: |
2035 |
|
begin |
2036 |
|
LocalDate := TimeStampToMSecs(DateTimeToTimeStamp(Qry[i].AsDateTime)); |
2037 |
< |
LocalData := PChar(@LocalDate); |
2037 |
> |
LocalData := PByte(@LocalDate); |
2038 |
|
end; |
2039 |
|
SQL_TYPE_DATE: |
2040 |
|
begin |
2041 |
|
LocalInt := DateTimeToTimeStamp(Qry[i].AsDateTime).Date; |
2042 |
< |
LocalData := PChar(@LocalInt); |
2042 |
> |
LocalData := PByte(@LocalInt); |
2043 |
|
end; |
2044 |
|
SQL_TYPE_TIME: |
2045 |
|
begin |
2046 |
|
LocalInt := DateTimeToTimeStamp(Qry[i].AsDateTime).Time; |
2047 |
< |
LocalData := PChar(@LocalInt); |
2047 |
> |
LocalData := PByte(@LocalInt); |
2048 |
|
end; |
2049 |
|
SQL_SHORT, SQL_LONG: |
2050 |
|
begin |
2051 |
|
if (fdDataScale = 0) then |
2052 |
|
begin |
2053 |
|
LocalInt := Qry[i].AsLong; |
2054 |
< |
LocalData := PChar(@LocalInt); |
2054 |
> |
LocalData := PByte(@LocalInt); |
2055 |
|
end |
2056 |
|
else |
2057 |
|
if (fdDataScale >= (-4)) then |
2058 |
|
begin |
2059 |
|
LocalCurrency := Qry[i].AsCurrency; |
2060 |
< |
LocalData := PChar(@LocalCurrency); |
2060 |
> |
LocalData := PByte(@LocalCurrency); |
2061 |
|
end |
2062 |
|
else |
2063 |
|
begin |
2064 |
|
LocalDouble := Qry[i].AsDouble; |
2065 |
< |
LocalData := PChar(@LocalDouble); |
2065 |
> |
LocalData := PByte(@LocalDouble); |
2066 |
|
end; |
2067 |
|
end; |
2068 |
|
SQL_INT64: |
2070 |
|
if (fdDataScale = 0) then |
2071 |
|
begin |
2072 |
|
LocalInt64 := Qry[i].AsInt64; |
2073 |
< |
LocalData := PChar(@LocalInt64); |
2073 |
> |
LocalData := PByte(@LocalInt64); |
2074 |
|
end |
2075 |
|
else |
2076 |
|
if (fdDataScale >= (-4)) then |
2077 |
|
begin |
2078 |
|
LocalCurrency := Qry[i].AsCurrency; |
2079 |
< |
LocalData := PChar(@LocalCurrency); |
2079 |
> |
LocalData := PByte(@LocalCurrency); |
2080 |
|
end |
2081 |
|
else |
2082 |
|
begin |
2083 |
|
LocalDouble := Qry[i].AsDouble; |
2084 |
< |
LocalData := PChar(@LocalDouble); |
2084 |
> |
LocalData := PByte(@LocalDouble); |
2085 |
|
end |
2086 |
|
end; |
2087 |
|
SQL_DOUBLE, SQL_FLOAT, SQL_D_FLOAT: |
2088 |
|
begin |
2089 |
|
LocalDouble := Qry[i].AsDouble; |
2090 |
< |
LocalData := PChar(@LocalDouble); |
2090 |
> |
LocalData := PByte(@LocalDouble); |
2091 |
|
end; |
2092 |
|
SQL_BOOLEAN: |
2093 |
|
begin |
2094 |
|
LocalBool := Qry[i].AsBoolean; |
2095 |
< |
LocalData := PChar(@LocalBool); |
2095 |
> |
LocalData := PByte(@LocalBool); |
2096 |
|
end; |
2097 |
|
end; |
2098 |
|
|
3675 |
|
var |
3676 |
|
FieldType: TFieldType; |
3677 |
|
FieldSize: Word; |
3678 |
+ |
FieldDataSize: integer; |
3679 |
|
charSetID: short; |
3680 |
|
CharSetSize: integer; |
3681 |
|
CharSetName: RawByteString; |
3812 |
|
FieldName := getSQLName; |
3813 |
|
FAliasNameList[i] := DBAliasName; |
3814 |
|
FieldSize := 0; |
3815 |
+ |
FieldDataSize := 0; |
3816 |
|
FieldPrecision := 0; |
3817 |
|
FieldNullable := IsNullable; |
3818 |
|
CharSetSize := 0; |
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 } |
3844 |
|
FieldType := ftBCD; |
3845 |
|
FieldPrecision := 4; |
3846 |
|
FieldSize := -getScale; |
3847 |
+ |
FieldDataSize := FieldSize; |
3848 |
|
end; |
3849 |
|
end; |
3850 |
|
SQL_LONG: |
3869 |
|
FieldPrecision := 9; |
3870 |
|
FieldSize := -getScale; |
3871 |
|
end; |
3872 |
+ |
FieldDataSize := FieldSize; |
3873 |
|
end; |
3874 |
|
|
3875 |
|
SQL_INT64: |
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; |
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 |
3931 |
|
Name := FieldAliasName; |
3932 |
|
FAliasNameMap[FieldNo-1] := DBAliasName; |
3933 |
|
Size := FieldSize; |
3934 |
+ |
DataSize := FieldDataSize; |
3935 |
|
Precision := FieldPrecision; |
3936 |
|
Required := not FieldNullable; |
3937 |
|
RelationName := aRelationName; |