diff options
| author | jonas <jonas@3ad0048d-3df7-0310-abae-a5850022a9f2> | 2015-01-21 23:28:34 +0000 |
|---|---|---|
| committer | jonas <jonas@3ad0048d-3df7-0310-abae-a5850022a9f2> | 2015-01-21 23:28:34 +0000 |
| commit | 1903b037de2fb3e75826406b46f055acb70963fa (patch) | |
| tree | 604cd8b790fe14e5fbe441d4cd647c80d2a36a9a /packages/fcl-db/src/sqlite | |
| parent | ad1141d52f8353457053b925cd674fe1d5c4eafc (diff) | |
| parent | 953d907e4d6c3a5c2f8aaee6e5e4f73c55ce5985 (diff) | |
| download | fpc-blocks.tar.gz | |
* synchronised with trunk till r29513blocks
git-svn-id: http://svn.freepascal.org/svn/fpc/branches/blocks@29516 3ad0048d-3df7-0310-abae-a5850022a9f2
Diffstat (limited to 'packages/fcl-db/src/sqlite')
| -rw-r--r-- | packages/fcl-db/src/sqlite/Makefile | 76 | ||||
| -rw-r--r-- | packages/fcl-db/src/sqlite/customsqliteds.pas | 91 | ||||
| -rw-r--r-- | packages/fcl-db/src/sqlite/sqlite3ds.pas | 20 | ||||
| -rw-r--r-- | packages/fcl-db/src/sqlite/sqliteds.pas | 30 |
4 files changed, 138 insertions, 79 deletions
diff --git a/packages/fcl-db/src/sqlite/Makefile b/packages/fcl-db/src/sqlite/Makefile index f308d859bb..1e0b553990 100644 --- a/packages/fcl-db/src/sqlite/Makefile +++ b/packages/fcl-db/src/sqlite/Makefile @@ -1,9 +1,9 @@ # -# Don't edit, this file is generated by FPCMake Version 2.0.0 [2014-02-06 rev 26692] +# Don't edit, this file is generated by FPCMake Version 2.0.0 [2014-12-07 rev 29213] # default: all -MAKEFILETARGETS=i386-linux i386-go32v2 i386-win32 i386-os2 i386-freebsd i386-beos i386-haiku i386-netbsd i386-solaris i386-qnx i386-netware i386-openbsd i386-wdosx i386-darwin i386-emx i386-watcom i386-netwlibc i386-wince i386-embedded i386-symbian i386-nativent i386-iphonesim i386-android m68k-linux m68k-freebsd m68k-netbsd m68k-amiga m68k-atari m68k-openbsd m68k-palmos m68k-embedded powerpc-linux powerpc-netbsd powerpc-amiga powerpc-macos powerpc-darwin powerpc-morphos powerpc-embedded powerpc-wii powerpc-aix sparc-linux sparc-netbsd sparc-solaris sparc-embedded x86_64-linux x86_64-freebsd x86_64-netbsd x86_64-solaris x86_64-openbsd x86_64-darwin x86_64-win64 x86_64-embedded arm-linux arm-palmos arm-darwin arm-wince arm-gba arm-nds arm-embedded arm-symbian arm-android powerpc64-linux powerpc64-darwin powerpc64-embedded powerpc64-aix avr-embedded armeb-linux armeb-embedded mips-linux mipsel-linux mipsel-android jvm-java jvm-android i8086-msdos -BSDs = freebsd netbsd openbsd darwin +MAKEFILETARGETS=i386-linux i386-go32v2 i386-win32 i386-os2 i386-freebsd i386-beos i386-haiku i386-netbsd i386-solaris i386-qnx i386-netware i386-openbsd i386-wdosx i386-darwin i386-emx i386-watcom i386-netwlibc i386-wince i386-embedded i386-symbian i386-nativent i386-iphonesim i386-android i386-aros m68k-linux m68k-freebsd m68k-netbsd m68k-amiga m68k-atari m68k-openbsd m68k-palmos m68k-embedded powerpc-linux powerpc-netbsd powerpc-amiga powerpc-macos powerpc-darwin powerpc-morphos powerpc-embedded powerpc-wii powerpc-aix sparc-linux sparc-netbsd sparc-solaris sparc-embedded x86_64-linux x86_64-freebsd x86_64-netbsd x86_64-solaris x86_64-openbsd x86_64-darwin x86_64-win64 x86_64-embedded x86_64-dragonfly arm-linux arm-palmos arm-darwin arm-wince arm-gba arm-nds arm-embedded arm-symbian arm-android powerpc64-linux powerpc64-darwin powerpc64-embedded powerpc64-aix avr-embedded armeb-linux armeb-embedded mips-linux mipsel-linux mipsel-embedded mipsel-android jvm-java jvm-android i8086-msdos +BSDs = freebsd netbsd openbsd darwin dragonfly UNIXs = linux $(BSDs) solaris qnx haiku aix LIMIT83fs = go32v2 os2 emx watcom msdos OSNeedsComspecToRunBatch = go32v2 watcom @@ -184,6 +184,12 @@ $(error When compiling for arm-embedded, a sub-architecture (e.g. SUBARCH=armv4t endif override FPCOPT+=-Cp$(SUBARCH) endif +ifeq ($(FULL_TARGET),mipsel-embedded) +ifeq ($(SUBARCH),) +$(error When compiling for mipsel-embedded, a sub-architecture (e.g. SUBARCH=pic32mx) must be defined) +endif +override FPCOPT+=-Cp$(SUBARCH) +endif ifneq ($(findstring $(OS_SOURCE),$(LIMIT83fs)),) TARGETSUFFIX=$(OS_TARGET) SOURCESUFFIX=$(OS_SOURCE) @@ -390,6 +396,9 @@ endif ifeq ($(FULL_TARGET),i386-android) override TARGET_UNITS+=customsqliteds sqliteds sqlite3ds endif +ifeq ($(FULL_TARGET),i386-aros) +override TARGET_UNITS+=customsqliteds sqliteds sqlite3ds +endif ifeq ($(FULL_TARGET),m68k-linux) override TARGET_UNITS+=customsqliteds sqliteds sqlite3ds endif @@ -477,6 +486,9 @@ endif ifeq ($(FULL_TARGET),x86_64-embedded) override TARGET_UNITS+=customsqliteds sqliteds sqlite3ds endif +ifeq ($(FULL_TARGET),x86_64-dragonfly) +override TARGET_UNITS+=customsqliteds sqliteds sqlite3ds +endif ifeq ($(FULL_TARGET),arm-linux) override TARGET_UNITS+=customsqliteds sqliteds sqlite3ds endif @@ -531,6 +543,9 @@ endif ifeq ($(FULL_TARGET),mipsel-linux) override TARGET_UNITS+=customsqliteds sqliteds sqlite3ds endif +ifeq ($(FULL_TARGET),mipsel-embedded) +override TARGET_UNITS+=customsqliteds sqliteds sqlite3ds +endif ifeq ($(FULL_TARGET),mipsel-android) override TARGET_UNITS+=customsqliteds sqliteds sqlite3ds endif @@ -786,6 +801,12 @@ EXEEXT= HASSHAREDLIB=1 SHORTSUFFIX=lnx endif +ifeq ($(OS_TARGET),dragonfly) +BATCHEXT=.sh +EXEEXT= +HASSHAREDLIB=1 +SHORTSUFFIX=df +endif ifeq ($(OS_TARGET),freebsd) BATCHEXT=.sh EXEEXT= @@ -831,6 +852,11 @@ EXEEXT= SHAREDLIBEXT=.library SHORTSUFFIX=amg endif +ifeq ($(OS_TARGET),aros) +EXEEXT= +SHAREDLIBEXT=.library +SHORTSUFFIX=aros +endif ifeq ($(OS_TARGET),morphos) EXEEXT= SHAREDLIBEXT=.library @@ -1413,6 +1439,16 @@ REQUIRE_PACKAGES_FPMKUNIT=1 REQUIRE_PACKAGES_SQLITE=1 REQUIRE_PACKAGES_FCL-BASE=1 endif +ifeq ($(FULL_TARGET),i386-aros) +REQUIRE_PACKAGES_RTL=1 +REQUIRE_PACKAGES_PASZLIB=1 +REQUIRE_PACKAGES_FCL-PROCESS=1 +REQUIRE_PACKAGES_HASH=1 +REQUIRE_PACKAGES_LIBTAR=1 +REQUIRE_PACKAGES_FPMKUNIT=1 +REQUIRE_PACKAGES_SQLITE=1 +REQUIRE_PACKAGES_FCL-BASE=1 +endif ifeq ($(FULL_TARGET),m68k-linux) REQUIRE_PACKAGES_RTL=1 REQUIRE_PACKAGES_PASZLIB=1 @@ -1703,6 +1739,16 @@ REQUIRE_PACKAGES_FPMKUNIT=1 REQUIRE_PACKAGES_SQLITE=1 REQUIRE_PACKAGES_FCL-BASE=1 endif +ifeq ($(FULL_TARGET),x86_64-dragonfly) +REQUIRE_PACKAGES_RTL=1 +REQUIRE_PACKAGES_PASZLIB=1 +REQUIRE_PACKAGES_FCL-PROCESS=1 +REQUIRE_PACKAGES_HASH=1 +REQUIRE_PACKAGES_LIBTAR=1 +REQUIRE_PACKAGES_FPMKUNIT=1 +REQUIRE_PACKAGES_SQLITE=1 +REQUIRE_PACKAGES_FCL-BASE=1 +endif ifeq ($(FULL_TARGET),arm-linux) REQUIRE_PACKAGES_RTL=1 REQUIRE_PACKAGES_PASZLIB=1 @@ -1883,6 +1929,16 @@ REQUIRE_PACKAGES_FPMKUNIT=1 REQUIRE_PACKAGES_SQLITE=1 REQUIRE_PACKAGES_FCL-BASE=1 endif +ifeq ($(FULL_TARGET),mipsel-embedded) +REQUIRE_PACKAGES_RTL=1 +REQUIRE_PACKAGES_PASZLIB=1 +REQUIRE_PACKAGES_FCL-PROCESS=1 +REQUIRE_PACKAGES_HASH=1 +REQUIRE_PACKAGES_LIBTAR=1 +REQUIRE_PACKAGES_FPMKUNIT=1 +REQUIRE_PACKAGES_SQLITE=1 +REQUIRE_PACKAGES_FCL-BASE=1 +endif ifeq ($(FULL_TARGET),mipsel-android) REQUIRE_PACKAGES_RTL=1 REQUIRE_PACKAGES_PASZLIB=1 @@ -2340,7 +2396,7 @@ endif ifdef CREATESHARED override FPCOPT+=-Cg endif -ifneq ($(findstring $(OS_TARGET),freebsd openbsd netbsd linux solaris),) +ifneq ($(findstring $(OS_TARGET),dragonfly freebsd openbsd netbsd linux solaris),) ifeq ($(CPU_TARGET),x86_64) override FPCOPT+=-Cg endif @@ -2370,17 +2426,23 @@ ifdef ACROSSCOMPILE override FPCOPT+=$(CROSSOPT) endif override COMPILER:=$(strip $(FPC) $(FPCOPT)) -ifeq (,$(findstring -s ,$(COMPILER))) +ifneq (,$(findstring -sh ,$(COMPILER))) +UseEXECPPAS=1 +endif +ifneq (,$(findstring -s ,$(COMPILER))) +ifeq ($(FULL_SOURCE),$(FULL_TARGET)) +UseEXECPPAS=1 +endif +endif +ifneq ($(UseEXECPPAS),1) EXECPPAS= else -ifeq ($(FULL_SOURCE),$(FULL_TARGET)) ifdef RUNBATCH EXECPPAS:=@$(RUNBATCH) $(PPAS) else EXECPPAS:=@$(PPAS) endif endif -endif .PHONY: fpc_units ifneq ($(TARGET_UNITS)$(TARGET_IMPLICITUNITS),) override ALLTARGET+=fpc_units diff --git a/packages/fcl-db/src/sqlite/customsqliteds.pas b/packages/fcl-db/src/sqlite/customsqliteds.pas index 6ee6dc3c53..fa9155004a 100644 --- a/packages/fcl-db/src/sqlite/customsqliteds.pas +++ b/packages/fcl-db/src/sqlite/customsqliteds.pas @@ -45,15 +45,12 @@ const DefaultStringSize = 255; type - {$if defined(ver2_6_0) or defined(ver2_4)} - TRecordBuffer = PAnsiChar; - {$endif} TCustomSqliteDataset = class; PDataRecord = ^DataRecord; PPDataRecord = ^PDataRecord; DataRecord = record - Row: PPChar; + Row: PPAnsiChar; BookmarkFlag: TBookmarkFlag; Next: PDataRecord; Previous: PDataRecord; @@ -65,7 +62,7 @@ type private FEditItem: PDataRecord; FDataset: TCustomSqliteDataset; - FFieldRow: PChar; + FFieldRow: PAnsiChar; FField: TField; FFieldOffset: Integer; FRowSize: Int64; @@ -84,8 +81,8 @@ type end; //callback types - TSqliteCdeclCallback = function(UserData: Pointer; Count: LongInt; Values: PPChar; Names: PPChar): LongInt; cdecl; - TSqliteCallback = function(UserData: Pointer; Count: LongInt; Values: PPChar; Names: PPChar): LongInt of object; + TSqliteCdeclCallback = function(UserData: Pointer; Count: LongInt; Values: PPAnsiChar; Names: PPAnsiChar): LongInt; cdecl; + TSqliteCallback = function(UserData: Pointer; Count: LongInt; Values: PPAnsiChar; Names: PPAnsiChar): LongInt of object; TCallbackInfo = record Proc: TSqliteCallback; Data: Pointer; @@ -94,9 +91,9 @@ type TRecordState = (rsAdded, rsDeleted, rsUpdated); TRecordStateSet = set of TRecordState; - TQueryUpdatesCallback = procedure(UserData: Pointer; Values: PPChar; ABookmark: TBookmark; RecordState: TRecordState) of object; + TQueryUpdatesCallback = procedure(UserData: Pointer; Values: PPAnsiChar; ABookmark: TBookmark; RecordState: TRecordState) of object; - TGetSqlStrFunction = function(APChar: PChar): String; + TGetSqlStrFunction = function(APChar: PAnsiChar): String; TSqliteOption = (soWildcardKey); TSqliteOptions = set of TSqliteOption; @@ -132,7 +129,7 @@ type protected FPrimaryKey: String; FPrimaryKeyNo: Integer; - FFileName: String; + FFileName: UTF8String; FSQL: String; FEffectiveSQL: String; FTableName: String; @@ -156,7 +153,7 @@ type FSaveOnRefetch: Boolean; FAutoIncrementKey: Boolean; FDataAllocated: Boolean; - function SqliteExec(Sql: PChar; ACallback: TSqliteCdeclCallback; Data: Pointer): Integer; virtual; abstract; + function SqliteExec(Sql: PAnsiChar; ACallback: TSqliteCdeclCallback; Data: Pointer): Integer; virtual; abstract; procedure InternalCloseHandle; virtual; abstract; function InternalGetHandle: Pointer; virtual; abstract; function FieldDefsStored: Boolean; @@ -171,7 +168,7 @@ type function GetMasterFields: String; procedure SetMasterSource(Value: TDataSource); function GetMasterSource: TDataSource; - procedure SetFileName(const Value: String); + procedure SetFileName(const Value: UTF8String); function GetRowsAffected: Integer; virtual; abstract; procedure RetrieveFieldDefs; virtual; abstract; //TDataSet overrides @@ -231,7 +228,7 @@ type procedure ExecSQL(ASqlList: TStrings); procedure ExecSQLList; procedure ExecuteDirect(const ASql: String); virtual; abstract; - function GetSQLValue(Values: PPChar; FieldIndex: Integer): String; + function GetSQLValue(Values: PPAnsiChar; FieldIndex: Integer): String; procedure QueryUpdates(RecordStates: TRecordStateSet; Callback: TQueryUpdatesCallback; UserData: Pointer = nil); function QuickQuery(const ASql: String):String;overload; function QuickQuery(const ASql: String; const AStrList: TStrings): String; overload; @@ -258,7 +255,7 @@ type published property AutoIncrementKey: Boolean read FAutoIncrementKey write FAutoIncrementKey default False; property IndexFieldNames: string read FIndexFieldNames write FIndexFieldNames; - property FileName: String read FFileName write SetFileName; + property FileName: UTF8String read FFileName write SetFileName; property OnCallback: TSqliteCallback read FOnCallback write FOnCallback; property OnGetHandle: TDataSetNotifyEvent read FOnGetHandle write FOnGetHandle; property Options: TSqliteOptions read FOptions write SetOptions default []; @@ -299,8 +296,8 @@ type property OnPostError; end; - function Num2SQLStr(APChar: PChar): String; - function Char2SQLStr(APChar: PChar): String; + function Num2SQLStr(APChar: PAnsiChar): String; + function Char2SQLStr(APChar: PAnsiChar): String; implementation @@ -316,13 +313,13 @@ const NullString = 'NULL'; -function CallbackDispatcher(UserData: Pointer; Count: LongInt; Values: PPchar; Names: PPchar): LongInt; cdecl; +function CallbackDispatcher(UserData: Pointer; Count: LongInt; Values: PPAnsiChar; Names: PPAnsiChar): LongInt; cdecl; begin with PCallbackInfo(UserData)^ do Result:= Proc(Data, Count, Values, Names); end; -function Num2SQLStr(APChar: PChar): String; +function Num2SQLStr(APChar: PAnsiChar): String; begin if APChar = nil then begin @@ -332,14 +329,14 @@ begin Result := String(APChar); end; -function Char2SQLStr(APChar: PChar): String; +function Char2SQLStr(APChar: PAnsiChar): String; begin if APChar = nil then begin Result := NullString; Exit; end; - //todo: create custom routine to directly transform PChar -> SQL str + //todo: create custom routine to directly transform PAnsiChar -> SQL str Result := String(APChar); if Pos('''', Result) > 0 then Result := AnsiReplaceStr(Result, '''', ''''''); @@ -394,7 +391,7 @@ end; function TDSStream.Write(const Buffer; Count: LongInt): LongInt; var - NewRow: PChar; + NewRow: PAnsiChar; begin Result := Count; if Count > 0 then @@ -703,7 +700,7 @@ function TCustomSqliteDataset.GetFieldData(Field: TField; Buffer: Pointer; NativeFormat: Boolean): Boolean; var ValError: Word; - FieldRow: PChar; + FieldRow: PAnsiChar; FieldOffset: Integer; begin if Field.FieldNo >= 0 then @@ -722,7 +719,7 @@ begin case Field.Datatype of ftString: begin - Move(FieldRow^, PChar(Buffer)^, StrLen(FieldRow) + 1); + Move(FieldRow^, PAnsiChar(Buffer)^, StrLen(FieldRow) + 1); end; ftInteger, ftAutoInc: begin @@ -1023,7 +1020,7 @@ begin end; type - TLocateCompareFunction = function (Value: PChar; const Key: String): Boolean; + TLocateCompareFunction = function (Value: PAnsiChar; const Key: String): Boolean; TLocateFieldInfo = record Index: Integer; @@ -1031,7 +1028,7 @@ type CompFunction: TLocateCompareFunction; end; -function CompInsensitivePartial(UTF8Value: PChar; const AnsiKey: String): Boolean; +function CompInsensitivePartial(UTF8Value: PAnsiChar; const AnsiKey: String): Boolean; var AnsiValue: AnsiString; begin @@ -1039,21 +1036,21 @@ begin if UTF8Value <> nil then begin AnsiValue := UTF8Decode(UTF8Value); - Result := AnsiStrLIComp(PChar(AnsiValue), PChar(AnsiKey), Length(AnsiKey)) = 0; + Result := AnsiStrLIComp(PAnsiChar(AnsiValue), PAnsiChar(AnsiKey), Length(AnsiKey)) = 0; end else Result := False; end; -function CompSensitivePartial(UTF8Value: PChar; const UTF8Key: String): Boolean; +function CompSensitivePartial(UTF8Value: PAnsiChar; const UTF8Key: String): Boolean; begin if UTF8Value <> nil then - Result := StrLComp(UTF8Value, PChar(UTF8Key), Length(UTF8Key)) = 0 + Result := StrLComp(UTF8Value, PAnsiChar(UTF8Key), Length(UTF8Key)) = 0 else Result := False; end; -function CompInsensitive(UTF8Value: PChar; const AnsiKey: String): Boolean; +function CompInsensitive(UTF8Value: PAnsiChar; const AnsiKey: String): Boolean; begin //fpc does not provide a function to compare UTF8 directly, so convert the //UTF8Value string to ansi through a temporary widestring and compare with the @@ -1067,15 +1064,15 @@ begin Result := False; end; -function CompSensitive(UTF8Value: PChar; const UTF8Key: String): Boolean; +function CompSensitive(UTF8Value: PAnsiChar; const UTF8Key: String): Boolean; begin if UTF8Value <> nil then - Result := StrComp(UTF8Value, PChar(UTF8Key)) = 0 + Result := StrComp(UTF8Value, PAnsiChar(UTF8Key)) = 0 else Result := False; end; -function CompSensitiveWild(UTF8Value: PChar; const UTF8Key: String): Boolean; +function CompSensitiveWild(UTF8Value: PAnsiChar; const UTF8Key: String): Boolean; begin if UTF8Value <> nil then Result := IsWild(String(UTF8Value), UTF8Key, False) @@ -1083,7 +1080,7 @@ begin Result := False; end; -function CompDouble(UTF8Value: PChar; const UTF8Key: String): Boolean; +function CompDouble(UTF8Value: PAnsiChar; const UTF8Key: String): Boolean; var e1,e2:double; begin if UTF8Value <> nil then @@ -1096,7 +1093,7 @@ begin Result := False; end; -function CompInsensitiveWild(UTF8Value: PChar; const AnsiKey: String): Boolean; +function CompInsensitiveWild(UTF8Value: PAnsiChar; const AnsiKey: String): Boolean; begin //IsWild does not work with UTF8 encoded strings for case insensitive searches, //so convert UTF8Value to the system ansi encoding before passing to IsWild. @@ -1363,13 +1360,13 @@ begin case Field.Datatype of ftString: begin - EditItem^.Row[FieldOffset] := StrNew(PChar(Buffer)); + EditItem^.Row[FieldOffset] := StrNew(PAnsiChar(Buffer)); end; ftInteger: begin Str(LongInt(Buffer^), TempStr); EditItem^.Row[FieldOffset] := StrAlloc(Length(TempStr) + 1); - Move(PChar(TempStr)^, (EditItem^.Row[FieldOffset])^, Length(TempStr) + 1); + Move(PAnsiChar(TempStr)^, (EditItem^.Row[FieldOffset])^, Length(TempStr) + 1); end; ftBoolean, ftWord: begin @@ -1379,19 +1376,19 @@ begin else Str(Word(Buffer^), TempStr); EditItem^.Row[FieldOffset] := StrAlloc(Length(TempStr) + 1); - Move(PChar(TempStr)^, (EditItem^.Row[FieldOffset])^, Length(TempStr) + 1); + Move(PAnsiChar(TempStr)^, (EditItem^.Row[FieldOffset])^, Length(TempStr) + 1); end; ftFloat, ftDateTime, ftDate, ftTime, ftCurrency: begin Str(Double(Buffer^), TempStr); EditItem^.Row[FieldOffset] := StrAlloc(Length(TempStr) + 1); - Move(PChar(TempStr)^, (EditItem^.Row[FieldOffset])^, Length(TempStr) + 1); + Move(PAnsiChar(TempStr)^, (EditItem^.Row[FieldOffset])^, Length(TempStr) + 1); end; ftLargeInt: begin Str(Int64(Buffer^), TempStr); EditItem^.Row[FieldOffset] := StrAlloc(Length(TempStr) + 1); - Move(PChar(TempStr)^, (EditItem^.Row[FieldOffset])^, Length(TempStr) + 1); + Move(PAnsiChar(TempStr)^, (EditItem^.Row[FieldOffset])^, Length(TempStr) + 1); end; end;// case end//if @@ -1517,7 +1514,7 @@ begin Result := FMasterLink.DataSource; end; -procedure TCustomSqliteDataset.SetFileName(const Value: String); +procedure TCustomSqliteDataset.SetFileName(const Value: UTF8String); begin if Value <> FFileName then begin @@ -1545,7 +1542,7 @@ procedure TCustomSqliteDataset.ExecSQL(ASqlList: TStrings); begin if FSqliteHandle = nil then GetSqliteHandle; - FReturnCode := SqliteExec(PChar(ASQLList.Text), nil, nil); + FReturnCode := SqliteExec(PAnsiChar(ASQLList.Text), nil, nil); if FReturnCode <> SQLITE_OK then DatabaseError(ReturnString, Self); end; @@ -1555,7 +1552,7 @@ begin ExecSQL(SQLList); end; -function TCustomSqliteDataset.GetSQLValue(Values: PPChar; FieldIndex: Integer): String; +function TCustomSqliteDataset.GetSQLValue(Values: PPAnsiChar; FieldIndex: Integer): String; begin if (State = dsInactive) or (FieldIndex < 0) or (FieldIndex >= FieldDefs.Count) then DatabaseError('Error retrieving SQL value: dataset inactive or field out of range', Self); @@ -1615,7 +1612,7 @@ begin if StatementsCounter = 400 then begin SQLTemp := SQLTemp + 'COMMIT;'; - FReturnCode := SqliteExec(PChar(SQLTemp), nil, nil); + FReturnCode := SqliteExec(PAnsiChar(SQLTemp), nil, nil); StatementsCounter := 0; SQLTemp := 'BEGIN;'; if FReturnCode <> SQLITE_OK then @@ -1649,7 +1646,7 @@ begin if StatementsCounter = 400 then begin SQLTemp := SQLTemp + 'COMMIT;'; - FReturnCode := SqliteExec(PChar(SQLTemp), nil, nil); + FReturnCode := SqliteExec(PAnsiChar(SQLTemp), nil, nil); StatementsCounter := 0; SQLTemp := 'BEGIN;'; if FReturnCode <> SQLITE_OK then @@ -1681,7 +1678,7 @@ begin if StatementsCounter = 400 then begin SQLTemp := SQLTemp + 'COMMIT;'; - FReturnCode := SqliteExec(PChar(SQLTemp), nil, nil); + FReturnCode := SqliteExec(PAnsiChar(SQLTemp), nil, nil); StatementsCounter := 0; SQLTemp := 'BEGIN;'; if FReturnCode <> SQLITE_OK then @@ -1698,7 +1695,7 @@ begin if FReturnCode = SQLITE_OK then begin SQLTemp := SQLTemp + 'COMMIT;'; - FReturnCode := SqliteExec(PChar(SQLTemp), nil, nil); + FReturnCode := SqliteExec(PAnsiChar(SQLTemp), nil, nil); if FReturnCode <> SQLITE_OK then SqliteExec('ROLLBACK;', nil, nil); end; @@ -1802,7 +1799,7 @@ begin GetSqliteHandle; CallbackInfo.Data := UserData; CallbackInfo.Proc := FOnCallback; - SqliteExec(PChar(ASQL), @CallbackDispatcher, @CallbackInfo); + SqliteExec(PAnsiChar(ASQL), @CallbackDispatcher, @CallbackInfo); end; diff --git a/packages/fcl-db/src/sqlite/sqlite3ds.pas b/packages/fcl-db/src/sqlite/sqlite3ds.pas index b5053d15af..a1ee5be8ce 100644 --- a/packages/fcl-db/src/sqlite/sqlite3ds.pas +++ b/packages/fcl-db/src/sqlite/sqlite3ds.pas @@ -51,7 +51,7 @@ type procedure InternalCloseHandle; override; function InternalGetHandle: Pointer; override; procedure RetrieveFieldDefs; override; - function SqliteExec(ASQL: PChar; ACallback: TSqliteCdeclCallback; Data: Pointer): Integer; override; + function SqliteExec(ASQL: PAnsiChar; ACallback: TSqliteCdeclCallback; Data: Pointer): Integer; override; public procedure ExecuteDirect(const ASQL: String); override; function QuickQuery(const ASQL: String; const AStrList: TStrings; FillObjects: Boolean): String; override; @@ -101,7 +101,7 @@ begin end; end; -function GetAutoIncValue(NextValue: Pointer; Columns: Integer; ColumnValues: PPChar; ColumnNames: PPChar): Integer; cdecl; +function GetAutoIncValue(NextValue: Pointer; Columns: Integer; ColumnValues: PPAnsiChar; ColumnNames: PPAnsiChar): Integer; cdecl; var CodeError, TempInt: Integer; begin @@ -118,7 +118,7 @@ end; { TSqlite3Dataset } -function TSqlite3Dataset.SqliteExec(ASQL: PChar; ACallback: TSqliteCdeclCallback; Data: Pointer): Integer; +function TSqlite3Dataset.SqliteExec(ASQL: PAnsiChar; ACallback: TSqliteCdeclCallback; Data: Pointer): Integer; begin Result := sqlite3_exec(FSqliteHandle, ASQL, ACallback, Data, nil); end; @@ -138,7 +138,7 @@ var vm: Pointer; ErrorStr: String; begin - sqlite3_open(PChar(FFileName), @Result); + sqlite3_open(PAnsiChar(FFileName), @Result); //sqlite3_open returns SQLITE_OK even for invalid files //do additional check here FReturnCode := sqlite3_prepare(Result, CheckFileSql, -1, @vm, nil); @@ -163,7 +163,7 @@ begin {$endif} FAutoIncFieldNo := -1; FieldDefs.Clear; - FReturnCode := sqlite3_prepare(FSqliteHandle, PChar(FEffectiveSQL), -1, @vm, nil); + FReturnCode := sqlite3_prepare(FSqliteHandle, PAnsiChar(FEffectiveSQL), -1, @vm, nil); if FReturnCode <> SQLITE_OK then DatabaseError(ReturnString, Self); sqlite3_step(vm); @@ -263,7 +263,7 @@ procedure TSqlite3Dataset.ExecuteDirect(const ASQL: String); var vm: Pointer; begin - FReturnCode := sqlite3_prepare(FSqliteHandle, Pchar(ASQL), -1, @vm, nil); + FReturnCode := sqlite3_prepare(FSqliteHandle, PAnsiChar(ASQL), -1, @vm, nil); if FReturnCode <> SQLITE_OK then DatabaseError(ReturnString, Self); FReturnCode := sqlite3_step(vm); @@ -278,10 +278,10 @@ var begin //Get AutoInc Field initial value if FAutoIncFieldNo <> -1 then - sqlite3_exec(FSqliteHandle, PChar('Select Max(' + FieldDefs[FAutoIncFieldNo].Name + + sqlite3_exec(FSqliteHandle, PAnsiChar('Select Max(' + FieldDefs[FAutoIncFieldNo].Name + ') from ' + FTableName), @GetAutoIncValue, @FNextAutoInc, nil); - FReturnCode := sqlite3_prepare(FSqliteHandle, PChar(FEffectiveSQL), -1, @vm, nil); + FReturnCode := sqlite3_prepare(FSqliteHandle, PAnsiChar(FEffectiveSQL), -1, @vm, nil); if FReturnCode <> SQLITE_OK then DatabaseError(ReturnString, Self); @@ -294,7 +294,7 @@ begin //add extra rows for calculated fields if FCalcFieldList <> nil then Inc(FRowCount, FCalcFieldList.Count); - FRowBufferSize := (SizeOf(PPChar) * FRowCount); + FRowBufferSize := (SizeOf(PPAnsiChar) * FRowCount); FReturnCode := sqlite3_step(vm); while FReturnCode = SQLITE_ROW do begin @@ -367,7 +367,7 @@ begin if FSqliteHandle = nil then GetSqliteHandle; Result := ''; - FReturnCode := sqlite3_prepare(FSqliteHandle,Pchar(ASQL), -1, @vm, nil); + FReturnCode := sqlite3_prepare(FSqliteHandle,PAnsiChar(ASQL), -1, @vm, nil); if FReturnCode <> SQLITE_OK then DatabaseError(ReturnString, Self); diff --git a/packages/fcl-db/src/sqlite/sqliteds.pas b/packages/fcl-db/src/sqlite/sqliteds.pas index fb8fc5c8d0..66e7ffed4a 100644 --- a/packages/fcl-db/src/sqlite/sqliteds.pas +++ b/packages/fcl-db/src/sqlite/sqliteds.pas @@ -53,7 +53,7 @@ type function InternalGetHandle: Pointer; override; procedure InternalCloseHandle; override; procedure RetrieveFieldDefs; override; - function SqliteExec(ASQL: PChar; ACallback: TSqliteCdeclCallback; Data: Pointer): Integer; override; + function SqliteExec(ASQL: PAnsiChar; ACallback: TSqliteCdeclCallback; Data: Pointer): Integer; override; public procedure ExecuteDirect(const ASQL: String); override; function QuickQuery(const ASQL: String; const AStrList: TStrings; FillObjects: Boolean): String; override; @@ -69,7 +69,7 @@ uses //function sqlite_last_statement_changes(dbhandle:Pointer):longint;cdecl;external 'sqlite' name 'sqlite_last_statement_changes'; -function GetAutoIncValue(NextValue: Pointer; Columns: Integer; ColumnValues: PPChar; ColumnNames: PPChar): Integer; cdecl; +function GetAutoIncValue(NextValue: Pointer; Columns: Integer; ColumnValues: PPAnsiChar; ColumnNames: PPAnsiChar): Integer; cdecl; var CodeError, TempInt: Integer; begin @@ -86,7 +86,7 @@ end; { TSqliteDataset } -function TSqliteDataset.SqliteExec(ASQL: PChar; ACallback: TSqliteCdeclCallback; Data: Pointer): Integer; +function TSqliteDataset.SqliteExec(ASQL: PAnsiChar; ACallback: TSqliteCdeclCallback; Data: Pointer): Integer; begin Result := sqlite_exec(FSqliteHandle, ASQL, ACallback, Data, nil); end; @@ -99,9 +99,9 @@ end; function TSqliteDataset.InternalGetHandle: Pointer; var - ErrorStr: PChar; + ErrorStr: PAnsiChar; begin - Result := sqlite_open(PChar(FFileName), 0, @ErrorStr); + Result := sqlite_open(PAnsiChar(FFileName), 0, @ErrorStr); if Result = nil then begin DatabaseError('Error opening "' + FFileName + '": ' + String(ErrorStr)); @@ -114,12 +114,12 @@ var ColumnCount, i, DataSize:Integer; AType: TFieldType; vm: Pointer; - ColumnNames, ColumnValues:PPChar; + ColumnNames, ColumnValues:PPAnsiChar; ColumnStr: String; begin FieldDefs.Clear; FAutoIncFieldNo := -1; - FReturnCode := sqlite_compile(FSqliteHandle, PChar(FEffectiveSQL), nil, @vm, nil); + FReturnCode := sqlite_compile(FSqliteHandle, PAnsiChar(FEffectiveSQL), nil, @vm, nil); if FReturnCode <> SQLITE_OK then DatabaseError(ReturnString, Self); sqlite_step(vm, @ColumnCount, @ColumnValues, @ColumnNames); @@ -207,10 +207,10 @@ end; procedure TSqliteDataset.ExecuteDirect(const ASQL: String); var vm: Pointer; - ColumnNames, ColumnValues: PPChar; + ColumnNames, ColumnValues: PPAnsiChar; ColCount: Integer; begin - FReturnCode := sqlite_compile(FSqliteHandle, Pchar(ASQL), nil, @vm, nil); + FReturnCode := sqlite_compile(FSqliteHandle, PAnsiChar(ASQL), nil, @vm, nil); if FReturnCode <> SQLITE_OK then DatabaseError(ReturnString,Self); @@ -223,15 +223,15 @@ procedure TSqliteDataset.BuildLinkedList; var TempItem: PDataRecord; vm: Pointer; - ColumnNames, ColumnValues: PPChar; + ColumnNames, ColumnValues: PPAnsiChar; Counter, ColumnCount: Integer; begin //Get AutoInc Field initial value if FAutoIncFieldNo <> -1 then - sqlite_exec(FSqliteHandle, PChar('Select Max(' + FieldDefs[FAutoIncFieldNo].Name + ') from ' + FTableName), + sqlite_exec(FSqliteHandle, PAnsiChar('Select Max(' + FieldDefs[FAutoIncFieldNo].Name + ') from ' + FTableName), @GetAutoIncValue, @FNextAutoInc, nil); - FReturnCode := sqlite_compile(FSqliteHandle, PChar(FEffectiveSQL), nil, @vm, nil); + FReturnCode := sqlite_compile(FSqliteHandle, PAnsiChar(FEffectiveSQL), nil, @vm, nil); if FReturnCode <> SQLITE_OK then DatabaseError(ReturnString, Self); @@ -244,7 +244,7 @@ begin //add extra rows for calculated fields if FCalcFieldList <> nil then Inc(FRowCount, FCalcFieldList.Count); - FRowBufferSize := (SizeOf(PPChar) * FRowCount); + FRowBufferSize := (SizeOf(PPAnsiChar) * FRowCount); while FReturnCode = SQLITE_ROW do begin @@ -339,7 +339,7 @@ end; function TSqliteDataset.QuickQuery(const ASQL: String; const AStrList: TStrings; FillObjects: Boolean): String; var vm: Pointer; - ColumnNames, ColumnValues: PPChar; + ColumnNames, ColumnValues: PPAnsiChar; ColCount: Integer; procedure FillStrings; @@ -364,7 +364,7 @@ begin if FSqliteHandle = nil then GetSqliteHandle; Result := ''; - FReturnCode := sqlite_compile(FSqliteHandle, PChar(ASQL), nil, @vm, nil); + FReturnCode := sqlite_compile(FSqliteHandle, PAnsiChar(ASQL), nil, @vm, nil); if FReturnCode <> SQLITE_OK then DatabaseError(ReturnString,Self); |
