33 |
|
|
34 |
|
unit IBCustomDataSet; |
35 |
|
|
36 |
+ |
{$IF FPC_FULLVERSION >= 20700 } |
37 |
+ |
{$codepage UTF8} |
38 |
+ |
{$DEFINE HAS_ANSISTRING_CODEPAGE} |
39 |
+ |
{$DEFINE NEW_TBOOKMARK} |
40 |
+ |
{$ENDIF} |
41 |
+ |
|
42 |
|
{$R-} |
43 |
|
|
44 |
|
{$Mode Delphi} |
98 |
|
fdDataSize: Short; |
99 |
|
fdDataLength: Short; |
100 |
|
fdDataOfs: Integer; |
101 |
+ |
{$IFDEF HAS_ANSISTRING_CODEPAGE} |
102 |
+ |
fdCodePage: TSystemCodePage; |
103 |
+ |
{$ENDIF} |
104 |
|
end; |
105 |
|
PFieldData = ^TFieldData; |
106 |
|
|
129 |
|
|
130 |
|
TIBStringField = class(TStringField) |
131 |
|
private |
132 |
< |
FCharacterSetName: string; |
132 |
> |
FCharacterSetName: RawByteString; |
133 |
|
FCharacterSetSize: integer; |
134 |
|
protected |
135 |
|
function GetDefaultWidth: Longint; override; |
140 |
|
function GetAsVariant: Variant; override; |
141 |
|
function GetValue(var Value: string): Boolean; |
142 |
|
procedure SetAsString(const Value: string); override; |
143 |
< |
property CharacterSetName: string read FCharacterSetName write FCharacterSetName; |
135 |
< |
property CharacterSetSize: integer read FCharacterSetSize write FCharacterSetSize; |
136 |
< |
end; |
137 |
< |
|
138 |
< |
{ TIBWideStringField } |
139 |
< |
|
140 |
< |
TIBWideStringField = class(TWideStringField) |
141 |
< |
private |
142 |
< |
FCharacterSetName: string; |
143 |
< |
FCharacterSetSize: integer; |
144 |
< |
public |
145 |
< |
property CharacterSetName: string read FCharacterSetName write FCharacterSetName; |
143 |
> |
property CharacterSetName: RawByteString read FCharacterSetName write FCharacterSetName; |
144 |
|
property CharacterSetSize: integer read FCharacterSetSize write FCharacterSetSize; |
145 |
+ |
{$IFDEF HAS_ANSISTRING_CODEPAGE} |
146 |
+ |
private |
147 |
+ |
FCodePage: TSystemCodePage; |
148 |
+ |
public |
149 |
+ |
property CodePage: TSystemCodePage read FCodePage write FCodePage; |
150 |
+ |
{$ENDIF} |
151 |
|
end; |
152 |
|
|
153 |
|
{ TIBBCDField } |
176 |
|
|
177 |
|
TIBMemoField = class(TMemoField) |
178 |
|
private |
179 |
< |
FCharacterSetName: string; |
179 |
> |
FCharacterSetName: RawByteString; |
180 |
|
FCharacterSetSize: integer; |
181 |
|
FDisplayTextAsClassName: boolean; |
182 |
|
function GetTruncatedText: string; |
183 |
|
protected |
184 |
+ |
function GetAsString: string; override; |
185 |
|
function GetDefaultWidth: Longint; override; |
186 |
|
procedure GetText(var AText: string; ADisplayText: Boolean); override; |
187 |
+ |
procedure SetAsString(const AValue: string); override; |
188 |
|
public |
189 |
|
constructor Create(AOwner: TComponent); override; |
190 |
< |
property CharacterSetName: string read FCharacterSetName write FCharacterSetName; |
190 |
> |
property CharacterSetName: RawByteString read FCharacterSetName write FCharacterSetName; |
191 |
|
property CharacterSetSize: integer read FCharacterSetSize write FCharacterSetSize; |
192 |
< |
published |
192 |
> |
published |
193 |
|
property DisplayTextAsClassName: boolean read FDisplayTextAsClassName |
194 |
|
write FDisplayTextAsClassName; |
195 |
< |
end; |
190 |
< |
|
191 |
< |
{ TIBWideMemoField } |
192 |
< |
|
193 |
< |
TIBWideMemoField = class(TWideMemoField) |
195 |
> |
{$IFDEF HAS_ANSISTRING_CODEPAGE} |
196 |
|
private |
197 |
< |
FCharacterSetName: string; |
198 |
< |
FCharacterSetSize: integer; |
197 |
< |
FDisplayTextAsClassName: boolean; |
198 |
< |
function GetTruncatedText: string; |
199 |
< |
protected |
200 |
< |
function GetDefaultWidth: Longint; override; |
201 |
< |
procedure GetText(var AText: string; ADisplayText: Boolean); override; |
197 |
> |
FCodePage: TSystemCodePage; |
198 |
> |
FFCodePage: TSystemCodePage; |
199 |
|
public |
200 |
< |
constructor Create(AOwner: TComponent); override; |
201 |
< |
property CharacterSetName: string read FCharacterSetName write FCharacterSetName; |
205 |
< |
property CharacterSetSize: integer read FCharacterSetSize write FCharacterSetSize; |
206 |
< |
published |
207 |
< |
property DisplayTextAsClassName: boolean read FDisplayTextAsClassName |
208 |
< |
write FDisplayTextAsClassName; |
200 |
> |
property CodePage: TSystemCodePage read FFCodePage write FFCodePage; |
201 |
> |
{$ENDIF} |
202 |
|
end; |
203 |
|
|
204 |
|
TIBDataLink = class(TDetailDataLink) |
712 |
|
protected |
713 |
|
FField: TField; |
714 |
|
FBlobStream: TIBBlobStream; |
715 |
+ |
function GetSize: Int64; override; |
716 |
|
public |
717 |
|
constructor Create(AField: TField; ABlobStream: TIBBlobStream; |
718 |
|
Mode: TBlobStreamMode); |
749 |
|
TBlobField, { ftTypedBinary } |
750 |
|
nil, { ftCursor } |
751 |
|
TStringField, { ftFixedChar } |
752 |
< |
TIBWideStringField, { ftWideString } |
752 |
> |
nil, { ftWideString } |
753 |
|
TLargeIntField, { ftLargeInt } |
754 |
|
nil, { ftADT } |
755 |
|
nil, { ftArray } |
764 |
|
TDateTimeField, {ftTimestamp} |
765 |
|
TIBBCDField, {ftFMTBcd} |
766 |
|
nil, {ftFixedWideChar} |
767 |
< |
TIBWideMemoField); {ftWideMemo} |
767 |
> |
nil); {ftWideMemo} |
768 |
|
(* |
769 |
|
TADTField, { ftADT } |
770 |
|
TArrayField, { ftArray } |
781 |
|
|
782 |
|
implementation |
783 |
|
|
784 |
< |
uses IBIntf, Variants, FmtBCD, LCLProc, LazUTF8; |
784 |
> |
uses IBIntf, Variants, FmtBCD, LazUTF8, IBCodePage; |
785 |
|
|
786 |
|
const FILE_BEGIN = 0; |
787 |
|
FILE_CURRENT = 1; |
810 |
|
|
811 |
|
TIBFieldDef = class(TFieldDef) |
812 |
|
private |
813 |
< |
FCharacterSetName: string; |
813 |
> |
FCharacterSetName: RawByteString; |
814 |
|
FCharacterSetSize: integer; |
815 |
+ |
{$IFDEF HAS_ANSISTRING_CODEPAGE} |
816 |
+ |
FCodePage: TSystemCodePage; |
817 |
+ |
{$ENDIF} |
818 |
|
published |
819 |
< |
property CharacterSetName: string read FCharacterSetName write FCharacterSetName; |
819 |
> |
property CharacterSetName: RawByteString read FCharacterSetName write FCharacterSetName; |
820 |
|
property CharacterSetSize: integer read FCharacterSetSize write FCharacterSetSize; |
821 |
+ |
{$IFDEF HAS_ANSISTRING_CODEPAGE} |
822 |
+ |
property CodePage: TSystemCodePage read FCodePage write FCodePage; |
823 |
+ |
{$ENDIF} |
824 |
|
end; |
825 |
|
|
826 |
– |
{ TIBWideMemoField } |
826 |
|
|
827 |
< |
function TIBWideMemoField.GetTruncatedText: string; |
829 |
< |
begin |
830 |
< |
Result := GetAsString; |
827 |
> |
{ Copied from LCLProc in order to avoid LCL dependency |
828 |
|
|
829 |
< |
if Result <> '' then |
830 |
< |
if DisplayWidth = 0 then |
831 |
< |
Result := TextToSingleLine(Result) |
832 |
< |
else |
833 |
< |
if Length(Result) > DisplayWidth then {Show truncation with elipses} |
834 |
< |
Result := TextToSingleLine(system.copy(Result,1,DisplayWidth-3)) + '...'; |
835 |
< |
end; |
836 |
< |
|
837 |
< |
function TIBWideMemoField.GetDefaultWidth: Longint; |
841 |
< |
begin |
842 |
< |
Result := 128; |
843 |
< |
end; |
844 |
< |
|
845 |
< |
procedure TIBWideMemoField.GetText(var AText: string; ADisplayText: Boolean); |
846 |
< |
begin |
847 |
< |
if ADisplayText then |
829 |
> |
Ensures the covenient look of multiline string |
830 |
> |
when displaying it in the single line |
831 |
> |
* Replaces CR and LF with spaces |
832 |
> |
* Removes duplicate spaces |
833 |
> |
} |
834 |
> |
function TextToSingleLine(const AText: string): string; |
835 |
> |
var |
836 |
> |
str: string; |
837 |
> |
i, wstart, wlen: Integer; |
838 |
|
begin |
839 |
< |
if not DisplayTextAsClassName then |
840 |
< |
AText := GetTruncatedText |
841 |
< |
else |
842 |
< |
inherited GetText(AText, ADisplayText); |
843 |
< |
end |
844 |
< |
else |
845 |
< |
AText := GetAsString; |
846 |
< |
end; |
847 |
< |
|
848 |
< |
constructor TIBWideMemoField.Create(AOwner: TComponent); |
849 |
< |
begin |
850 |
< |
inherited Create(AOwner); |
851 |
< |
BlobType := ftWideMemo; |
852 |
< |
end; |
839 |
> |
str := Trim(AText); |
840 |
> |
wstart := 0; |
841 |
> |
wlen := 0; |
842 |
> |
i := 1; |
843 |
> |
while i < Length(str) - 1 do |
844 |
> |
begin |
845 |
> |
if (str[i] in [' ', #13, #10]) then |
846 |
> |
begin |
847 |
> |
if (wstart = 0) then |
848 |
> |
begin |
849 |
> |
wstart := i; |
850 |
> |
wlen := 1; |
851 |
> |
end else |
852 |
> |
Inc(wlen); |
853 |
> |
end else |
854 |
> |
begin |
855 |
> |
if wstart > 0 then |
856 |
> |
begin |
857 |
> |
str[wstart] := ' '; |
858 |
> |
Delete(str, wstart+1, wlen-1); |
859 |
> |
Dec(i, wlen-1); |
860 |
> |
wstart := 0; |
861 |
> |
end; |
862 |
> |
end; |
863 |
> |
Inc(i); |
864 |
> |
end; |
865 |
> |
Result := str; |
866 |
> |
end; |
867 |
|
|
868 |
|
{ TIBMemoField } |
869 |
|
|
894 |
|
end |
895 |
|
end; |
896 |
|
|
897 |
+ |
function TIBMemoField.GetAsString: string; |
898 |
+ |
var s: RawByteString; |
899 |
+ |
begin |
900 |
+ |
s := inherited GetAsString; |
901 |
+ |
{$IFDEF HAS_ANSISTRING_CODEPAGE} |
902 |
+ |
SetCodePage(s,CodePage,false); |
903 |
+ |
if (CodePage <> CP_NONE) and (CodePage <> CP_UTF8) then |
904 |
+ |
SetCodePage(s,CP_UTF8,true); {LCL only accepts UTF8} |
905 |
+ |
{$ENDIF} |
906 |
+ |
Result := s; |
907 |
+ |
end; |
908 |
+ |
|
909 |
|
function TIBMemoField.GetDefaultWidth: Longint; |
910 |
|
begin |
911 |
< |
Result := 128; |
911 |
> |
if DisplayTextAsClassName then |
912 |
> |
Result := inherited |
913 |
> |
else |
914 |
> |
Result := 128; |
915 |
|
end; |
916 |
|
|
917 |
|
procedure TIBMemoField.GetText(var AText: string; ADisplayText: Boolean); |
918 |
|
begin |
919 |
|
if ADisplayText then |
920 |
|
begin |
921 |
< |
if not DisplayTextAsClassName then |
921 |
> |
if not DisplayTextAsClassName and (CharacterSetName <> '') then |
922 |
|
AText := GetTruncatedText |
923 |
|
else |
924 |
|
inherited GetText(AText, ADisplayText); |
927 |
|
AText := GetAsString; |
928 |
|
end; |
929 |
|
|
930 |
+ |
procedure TIBMemoField.SetAsString(const AValue: string); |
931 |
+ |
var s: RawByteString; |
932 |
+ |
begin |
933 |
+ |
s := AValue; |
934 |
+ |
{$IFDEF HAS_ANSISTRING_CODEPAGE} |
935 |
+ |
if StringCodePage(Value) <> CodePage then |
936 |
+ |
SetCodePage(s,CodePage,CodePage<>CP_NONE); |
937 |
+ |
{$ENDIF} |
938 |
+ |
inherited SetAsString(s); |
939 |
+ |
end; |
940 |
+ |
|
941 |
|
constructor TIBMemoField.Create(AOwner: TComponent); |
942 |
|
begin |
943 |
|
inherited Create(AOwner); |
944 |
|
BlobType := ftMemo; |
945 |
+ |
{$IFDEF HAS_ANSISTRING_CODEPAGE} |
946 |
+ |
FCodePage := CP_NONE; |
947 |
+ |
{$ENDIF} |
948 |
|
end; |
949 |
|
|
950 |
|
{ TIBControlLink } |
987 |
|
begin |
988 |
|
inherited Create(aOwner); |
989 |
|
FCharacterSetSize := 1; |
990 |
+ |
{$IFDEF HAS_ANSISTRING_CODEPAGE} |
991 |
+ |
FCodePage := CP_NONE; |
992 |
+ |
{$ENDIF} |
993 |
|
end; |
994 |
|
|
995 |
|
class procedure TIBStringField.CheckTypeSize(Value: Integer); |
1012 |
|
function TIBStringField.GetValue(var Value: string): Boolean; |
1013 |
|
var |
1014 |
|
Buffer: PChar; |
1015 |
+ |
s: RawByteString; |
1016 |
+ |
// i: integer; |
1017 |
|
begin |
1018 |
|
Buffer := nil; |
1019 |
|
IBAlloc(Buffer, 0, Size + 1); |
1021 |
|
Result := GetData(Buffer); |
1022 |
|
if Result then |
1023 |
|
begin |
1024 |
+ |
{$IFDEF HAS_ANSISTRING_CODEPAGE} |
1025 |
+ |
s := string(Buffer); |
1026 |
+ |
SetCodePage(s,CodePage,false); |
1027 |
+ |
if (CodePage <> CP_NONE) and (CodePage <> CP_UTF8) then |
1028 |
+ |
SetCodePage(s,CP_UTF8,true); {LCL only accepts UTF8} |
1029 |
+ |
Value := s; |
1030 |
+ |
(* write(FieldName,': ', StringCodePage(Value),', ',Value,' '); |
1031 |
+ |
for i := 1 to Length(Value) do |
1032 |
+ |
write(Format('%x ',[byte(Value[i])])); |
1033 |
+ |
writeln;*) |
1034 |
+ |
{$ELSE} |
1035 |
|
Value := string(Buffer); |
1036 |
+ |
{$ENDIF} |
1037 |
|
if Transliterate and (Value <> '') then |
1038 |
|
DataSet.Translate(PChar(Value), PChar(Value), False); |
1039 |
|
end |
1045 |
|
procedure TIBStringField.SetAsString(const Value: string); |
1046 |
|
var |
1047 |
|
Buffer: PChar; |
1048 |
+ |
s: RawByteString; |
1049 |
|
begin |
1050 |
|
Buffer := nil; |
1051 |
|
IBAlloc(Buffer, 0, Size + 1); |
1052 |
|
try |
1053 |
< |
StrLCopy(Buffer, PChar(Value), Size); |
1053 |
> |
s := Value; |
1054 |
> |
{$IFDEF HAS_ANSISTRING_CODEPAGE} |
1055 |
> |
if StringCodePage(s) <> CodePage then |
1056 |
> |
SetCodePage(s,CodePage,CodePage<>CP_NONE); |
1057 |
> |
{$ENDIF} |
1058 |
> |
StrLCopy(Buffer, PChar(s), Size); |
1059 |
|
if Transliterate then |
1060 |
|
DataSet.Translate(Buffer, Buffer, True); |
1061 |
|
SetData(Buffer); |
1271 |
|
|
1272 |
|
procedure TIBCustomDataSet.ApplyUpdates; |
1273 |
|
var |
1274 |
< |
{$IF FPC_FULLVERSION >= 20700 } |
1274 |
> |
{$IFDEF NEW_TBOOKMARK } |
1275 |
|
CurBookmark: TBookmark; |
1276 |
|
{$ELSE} |
1277 |
|
CurBookmark: string; |
1715 |
|
LocalInt64: Int64; |
1716 |
|
LocalCurrency: Currency; |
1717 |
|
FieldsLoaded: Integer; |
1662 |
– |
temp: TIBXSQLVAR; |
1718 |
|
begin |
1719 |
|
p := PRecordData(Buffer); |
1720 |
|
{ Make sure blob cache is empty } |
1763 |
|
(Qry.Current[i].Data^.sqltype and 1 = 1); |
1764 |
|
rdFields[j].fdIsNull := |
1765 |
|
(rdFields[j].fdNullable and (Qry.Current[i].Data^.sqlind^ = -1)); |
1766 |
+ |
{$IFDEF HAS_ANSISTRING_CODEPAGE} |
1767 |
+ |
rdFields[j].fdCodePage := 0; |
1768 |
+ |
{$ENDIF} |
1769 |
|
LocalData := Qry.Current[i].Data^.sqldata; |
1770 |
|
case rdFields[j].fdDataType of |
1771 |
|
SQL_TIMESTAMP: |
1846 |
|
begin |
1847 |
|
rdFields[j].fdDataSize := Qry.Current[i].Data^.sqllen; |
1848 |
|
rdFields[j].fdDataLength := isc_vax_integer(Qry.Current[i].Data^.sqldata, 2); |
1849 |
+ |
{$IFDEF HAS_ANSISTRING_CODEPAGE} |
1850 |
+ |
TFirebirdCharacterSets.CharSetID2CodePage(Qry.Current[i].Data^.sqlsubtype and $FF, |
1851 |
+ |
rdFields[j].fdCodePage); |
1852 |
+ |
{$ENDIF} |
1853 |
|
if RecordNumber >= 0 then |
1854 |
|
begin |
1855 |
|
if (rdFields[j].fdDataLength = 0) then |
1856 |
|
LocalData := nil |
1857 |
|
else |
1858 |
< |
begin |
1797 |
< |
temp := Qry.Current[i]; |
1798 |
< |
LocalData := @temp.Data^.sqldata[2]; |
1799 |
< |
(* LocalData := @Qry.Current[i].Data^.sqldata[2];*) |
1800 |
< |
end; |
1858 |
> |
Inc(LocalData,2); |
1859 |
|
end; |
1860 |
|
end; |
1861 |
|
SQL_BOOLEAN: |
1866 |
|
LocalBool := Qry.Current[i].AsBoolean; |
1867 |
|
LocalData := PChar(@LocalBool); |
1868 |
|
end; |
1869 |
< |
else { SQL_TEXT, SQL_BLOB, SQL_ARRAY, SQL_QUAD } |
1869 |
> |
SQL_TEXT: |
1870 |
> |
begin |
1871 |
> |
rdFields[j].fdDataSize := Qry.Current[i].Data^.sqllen; |
1872 |
> |
rdFields[j].fdDataLength := rdFields[j].fdDataSize; |
1873 |
> |
{$IFDEF HAS_ANSISTRING_CODEPAGE} |
1874 |
> |
TFirebirdCharacterSets.CharSetID2CodePage(Qry.Current[i].Data^.sqlsubtype and $FF, |
1875 |
> |
rdFields[j].fdCodePage); |
1876 |
> |
{$ENDIF} |
1877 |
> |
end; |
1878 |
> |
else { SQL_BLOB, SQL_ARRAY, SQL_QUAD } |
1879 |
|
begin |
1880 |
|
rdFields[j].fdDataSize := Qry.Current[i].Data^.sqllen; |
1814 |
– |
if (rdFields[j].fdDataType = SQL_TEXT) then |
1815 |
– |
rdFields[j].fdDataLength := rdFields[j].fdDataSize; |
1881 |
|
end; |
1882 |
|
end; |
1883 |
|
if RecordNumber < 0 then |
2015 |
|
const KeyValues: Variant; Options: TLocateOptions): Boolean; |
2016 |
|
var |
2017 |
|
keyFieldList: TList; |
2018 |
< |
{$IF FPC_FULLVERSION >= 20700 } |
2018 |
> |
{$IFDEF NEW_TBOOKMARK } |
2019 |
|
CurBookmark: TBookmark; |
2020 |
|
{$ELSE} |
2021 |
|
CurBookmark: string; |
2412 |
|
var |
2413 |
|
i, j: Integer; |
2414 |
|
cr, data: PChar; |
2415 |
< |
fn, st: string; |
2415 |
> |
fn: string; |
2416 |
> |
st: RawByteString; |
2417 |
|
OldBuffer: Pointer; |
2418 |
|
ts: TTimeStamp; |
2419 |
|
begin |
2461 |
|
SQL_TEXT, SQL_VARYING: |
2462 |
|
begin |
2463 |
|
SetString(st, data, rdFields[j].fdDataLength); |
2464 |
+ |
{$IFDEF HAS_ANSISTRING_CODEPAGE} |
2465 |
+ |
SetCodePage(st,rdFields[j].fdCodePage,false); |
2466 |
+ |
{$ENDIF} |
2467 |
|
Qry.Params[i].AsString := st; |
2468 |
|
end; |
2469 |
|
SQL_FLOAT, SQL_DOUBLE, SQL_D_FLOAT: |
2961 |
|
|
2962 |
|
procedure TIBCustomDataSet.FetchAll; |
2963 |
|
var |
2964 |
< |
{$IF FPC_FULLVERSION >= 20700 } |
2964 |
> |
{$IFDEF NEW_TBOOKMARK } |
2965 |
|
CurBookmark: TBookmark; |
2966 |
|
{$ELSE} |
2967 |
|
CurBookmark: string; |
3384 |
|
var |
3385 |
|
FieldType: TFieldType; |
3386 |
|
FieldSize: Word; |
3387 |
< |
charSetID: short; |
3387 |
> |
charSetID: integer; |
3388 |
|
CharSetSize: integer; |
3389 |
< |
CharSetName: string; |
3389 |
> |
CharSetName: RawByteString; |
3390 |
> |
{$IFDEF HAS_ANSISTRING_CODEPAGE} |
3391 |
> |
FieldCodePage: TSystemCodePage; |
3392 |
> |
{$ENDIF} |
3393 |
|
FieldNullable : Boolean; |
3394 |
|
i, FieldPosition, FieldPrecision: Integer; |
3395 |
|
FieldAliasName, DBAliasName: string; |
3522 |
|
FieldNullable := SourceQuery.Current[i].IsNullable; |
3523 |
|
CharSetSize := 0; |
3524 |
|
CharSetName := ''; |
3525 |
+ |
{$IFDEF HAS_ANSISTRING_CODEPAGE} |
3526 |
+ |
FieldCodePage := CP_NONE; |
3527 |
+ |
{$ENDIF} |
3528 |
|
case sqltype and not 1 of |
3529 |
|
{ All VARCHAR's must be converted to strings before recording |
3530 |
|
their values } |
3531 |
|
SQL_VARYING, SQL_TEXT: |
3532 |
|
begin |
3533 |
< |
CharSetSize := FBase.GetCharSetSize(sqlsubtype and $FF); |
3534 |
< |
CharSetName := FBase.GetCharSetName(sqlsubtype and $FF); |
3535 |
< |
{FieldSize is encoded for strings - see TIBStringField.SetSize for decode} |
3533 |
> |
CharSetID := SourceQuery.Current[i].GetCharSetID; |
3534 |
> |
TFirebirdCharacterSets.CharSetWidth(CharSetID,CharSetSize); |
3535 |
> |
CharSetName := TFirebirdCharacterSets.GetCharsetName(CharSetID); |
3536 |
> |
{$IFDEF HAS_ANSISTRING_CODEPAGE} |
3537 |
> |
TFirebirdCharacterSets.CharSetID2CodePage(CharSetID,FieldCodePage); |
3538 |
> |
{$ENDIF} |
3539 |
|
FieldSize := sqllen; |
3540 |
< |
if CharSetSize = 2 then |
3463 |
< |
FieldType := ftWideString |
3464 |
< |
else |
3465 |
< |
FieldType := ftString; |
3540 |
> |
FieldType := ftString; |
3541 |
|
end; |
3542 |
|
{ All Doubles/Floats should be cast to doubles } |
3543 |
|
SQL_DOUBLE, SQL_FLOAT: |
3597 |
|
FieldSize := sizeof (TISC_QUAD); |
3598 |
|
if (sqlsubtype = 1) then |
3599 |
|
begin |
3600 |
< |
if strpas(sqlname) = '' then {Complex SQL with no identifiable column - use connection default} |
3601 |
< |
begin |
3602 |
< |
CharSetSize := FBase.GetDefaultCharSetSize; |
3603 |
< |
CharSetName := FBase.GetDefaultCharSetName; |
3604 |
< |
end |
3605 |
< |
else |
3606 |
< |
begin |
3532 |
< |
charSetID := GetBlobCharSetID(Database.Handle,Database.InternalTransaction.Handle, |
3533 |
< |
@relname,@sqlname); |
3534 |
< |
CharSetSize := FBase.GetCharSetSize(charSetID); |
3535 |
< |
CharSetName := FBase.GetCharSetName(charSetID); |
3536 |
< |
end; |
3537 |
< |
if CharSetSize = 2 then |
3538 |
< |
FieldType := ftWideMemo |
3539 |
< |
else |
3540 |
< |
FieldType := ftMemo; |
3600 |
> |
CharSetID := SourceQuery.Current[i].GetCharSetID; |
3601 |
> |
TFirebirdCharacterSets.CharSetWidth(CharSetID,CharSetSize); |
3602 |
> |
CharSetName := TFirebirdCharacterSets.GetCharsetName(CharSetID); |
3603 |
> |
{$IFDEF HAS_ANSISTRING_CODEPAGE} |
3604 |
> |
TFirebirdCharacterSets.CharSetID2CodePage(CharSetID,FieldCodePage); |
3605 |
> |
{$ENDIF} |
3606 |
> |
FieldType := ftMemo; |
3607 |
|
end |
3608 |
|
else |
3609 |
|
FieldType := ftBlob; |
3633 |
|
InternalCalcField := False; |
3634 |
|
CharacterSetSize := CharSetSize; |
3635 |
|
CharacterSetName := CharSetName; |
3636 |
+ |
{$IFDEF HAS_ANSISTRING_CODEPAGE} |
3637 |
+ |
CodePage := FieldCodePage; |
3638 |
+ |
{$ENDIF} |
3639 |
|
if (FieldName <> '') and (RelationName <> '') then |
3640 |
|
begin |
3641 |
|
if Has_COMPUTED_BLR(RelationName, FieldName) then |
3803 |
|
begin |
3804 |
|
CharacterSetSize := IBFieldDef.CharacterSetSize; |
3805 |
|
CharacterSetName := IBFieldDef.CharacterSetName; |
3806 |
< |
end; |
3807 |
< |
end |
3808 |
< |
else |
3740 |
< |
if(Fields[i] is TIBWideStringField) then |
3741 |
< |
with TIBWideStringField(Fields[i]) do |
3742 |
< |
begin |
3743 |
< |
IBFieldDef := GetFieldDef(FieldNo); |
3744 |
< |
if IBFieldDef <> nil then |
3745 |
< |
begin |
3746 |
< |
CharacterSetSize := IBFieldDef.CharacterSetSize; |
3747 |
< |
CharacterSetName := IBFieldDef.CharacterSetName; |
3806 |
> |
{$IFDEF HAS_ANSISTRING_CODEPAGE} |
3807 |
> |
CodePage := IBFieldDef.CodePage; |
3808 |
> |
{$ENDIF} |
3809 |
|
end; |
3810 |
|
end |
3811 |
|
else |
3817 |
|
begin |
3818 |
|
CharacterSetSize := IBFieldDef.CharacterSetSize; |
3819 |
|
CharacterSetName := IBFieldDef.CharacterSetName; |
3820 |
< |
end; |
3821 |
< |
end |
3822 |
< |
else |
3762 |
< |
if(Fields[i] is TIBWideMemoField) then |
3763 |
< |
with TIBWideMemoField(Fields[i]) do |
3764 |
< |
begin |
3765 |
< |
IBFieldDef := GetFieldDef(FieldNo); |
3766 |
< |
if IBFieldDef <> nil then |
3767 |
< |
begin |
3768 |
< |
CharacterSetSize := IBFieldDef.CharacterSetSize; |
3769 |
< |
CharacterSetName := IBFieldDef.CharacterSetName; |
3820 |
> |
{$IFDEF HAS_ANSISTRING_CODEPAGE} |
3821 |
> |
CodePage := IBFieldDef.CodePage; |
3822 |
> |
{$ENDIF} |
3823 |
|
end; |
3824 |
|
end |
3825 |
|
end |
3978 |
|
function TIBCustomDataSet.Locate(const KeyFields: string; const KeyValues: Variant; |
3979 |
|
Options: TLocateOptions): Boolean; |
3980 |
|
var |
3981 |
< |
{$IF FPC_FULLVERSION >= 20700 } |
3981 |
> |
{$IFDEF NEW_TBOOKMARK } |
3982 |
|
CurBookmark: TBookmark; |
3983 |
|
{$ELSE} |
3984 |
|
CurBookmark: string; |
4000 |
|
const ResultFields: string): Variant; |
4001 |
|
var |
4002 |
|
fl: TList; |
4003 |
< |
{$IF FPC_FULLVERSION >= 20700 } |
4003 |
> |
{$IFDEF NEW_TBOOKMARK } |
4004 |
|
CurBookmark: TBookmark; |
4005 |
|
{$ELSE} |
4006 |
|
CurBookmark: string; |
4584 |
|
DataSet.SetInternalSQLParams(Query, buff); |
4585 |
|
end; |
4586 |
|
|
4587 |
+ |
function TIBDSBlobStream.GetSize: Int64; |
4588 |
+ |
begin |
4589 |
+ |
Result := FBlobStream.BlobSize; |
4590 |
+ |
end; |
4591 |
+ |
|
4592 |
|
{ TIBDSBlobStream } |
4593 |
|
constructor TIBDSBlobStream.Create(AField: TField; ABlobStream: TIBBlobStream; |
4594 |
|
Mode: TBlobStreamMode); |
4597 |
|
FBlobStream := ABlobStream; |
4598 |
|
FBlobStream.Seek(0, soFromBeginning); |
4599 |
|
if (Mode = bmWrite) then |
4600 |
+ |
begin |
4601 |
|
FBlobStream.Truncate; |
4602 |
+ |
TIBCustomDataSet(FField.DataSet).RecordModified(True); |
4603 |
+ |
TBlobField(FField).Modified := true; |
4604 |
+ |
FHasWritten := true; |
4605 |
+ |
end; |
4606 |
|
end; |
4607 |
|
|
4608 |
|
destructor TIBDSBlobStream.Destroy; |