mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-08-14 21:09:11 +02:00
* Removed unused method StringQuery
* Fix for Execscallback * Set ConnOptions * Set FPrepared flag on prepare and call sqlite3_reset before execute git-svn-id: trunk@10884 -
This commit is contained in:
parent
6d3a7cbc34
commit
2788fec70e
@ -50,7 +50,6 @@ type
|
|||||||
foptions: TSQLiteOptions;
|
foptions: TSQLiteOptions;
|
||||||
procedure setoptions(const avalue: tsqliteoptions);
|
procedure setoptions(const avalue: tsqliteoptions);
|
||||||
protected
|
protected
|
||||||
function stringquery(const asql: string): TStringArray;
|
|
||||||
function stringsquery(const asql: string): TArrayStringArray;
|
function stringsquery(const asql: string): TArrayStringArray;
|
||||||
procedure checkerror(const aerror: integer);
|
procedure checkerror(const aerror: integer);
|
||||||
|
|
||||||
@ -82,13 +81,14 @@ type
|
|||||||
procedure LoadBlobIntoBuffer(FieldDef: TFieldDef;ABlobBuf: PBufBlobField; cursor: TSQLCursor; ATransaction : TSQLTransaction); override;
|
procedure LoadBlobIntoBuffer(FieldDef: TFieldDef;ABlobBuf: PBufBlobField; cursor: TSQLCursor; ATransaction : TSQLTransaction); override;
|
||||||
// New methods
|
// New methods
|
||||||
procedure execsql(const asql: string);
|
procedure execsql(const asql: string);
|
||||||
procedure UpdateIndexDefs(var IndexDefs : TIndexDefs; const TableName : string); // Differs from SQLDB.
|
procedure UpdateIndexDefs(IndexDefs : TIndexDefs;TableName : string); override; // Differs from SQLDB.
|
||||||
function getprimarykeyfield(const atablename: string; const acursor: tsqlcursor): string;
|
function getprimarykeyfield(const atablename: string; const acursor: tsqlcursor): string;
|
||||||
function RowsAffected(cursor: TSQLCursor): TRowsCount; override;
|
function RowsAffected(cursor: TSQLCursor): TRowsCount; override;
|
||||||
function GetSchemaInfoSQL(SchemaType : TSchemaType; SchemaObjectName, SchemaPattern : string) : string; override;
|
function GetSchemaInfoSQL(SchemaType : TSchemaType; SchemaObjectName, SchemaPattern : string) : string; override;
|
||||||
function StrToStatementType(s : string) : TStatementType; override;
|
function StrToStatementType(s : string) : TStatementType; override;
|
||||||
public
|
public
|
||||||
function GetInsertID: int64;
|
constructor Create(AOwner : TComponent); override;
|
||||||
|
function GetInsertID: int64;
|
||||||
procedure GetFieldNames(const TableName : string; List : TStrings); override;
|
procedure GetFieldNames(const TableName : string; List : TStrings); override;
|
||||||
published
|
published
|
||||||
property Options: TSqliteOptions read FOptions write SetOptions;
|
property Options: TSqliteOptions read FOptions write SetOptions;
|
||||||
@ -202,12 +202,14 @@ begin
|
|||||||
if assigned(aparams) and (aparams.count > 0) then
|
if assigned(aparams) and (aparams.count > 0) then
|
||||||
buf := aparams.parsesql(buf,false,false,false,psinterbase,fparambinding);
|
buf := aparams.parsesql(buf,false,false,false,psinterbase,fparambinding);
|
||||||
checkerror(sqlite3_prepare(fhandle,pchar(buf),length(buf),@fstatement,@ftail));
|
checkerror(sqlite3_prepare(fhandle,pchar(buf),length(buf),@fstatement,@ftail));
|
||||||
|
FPrepared:=True;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
Procedure TSQLite3Cursor.UnPrepare;
|
Procedure TSQLite3Cursor.UnPrepare;
|
||||||
|
|
||||||
begin
|
begin
|
||||||
sqlite3_finalize(fstatement); // No check.
|
sqlite3_finalize(fstatement); // No check.
|
||||||
|
FPrepared:=False;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
Procedure TSQLite3Cursor.Execute;
|
Procedure TSQLite3Cursor.Execute;
|
||||||
@ -226,8 +228,8 @@ begin
|
|||||||
finally
|
finally
|
||||||
set8087cw(wo1); //restore
|
set8087cw(wo1); //restore
|
||||||
end;
|
end;
|
||||||
{$endif}
|
{$endif}
|
||||||
if (fstate<=sqliteerrormax) then
|
if (fstate<=sqliteerrormax) then
|
||||||
checkerror(sqlite3_reset(fstatement));
|
checkerror(sqlite3_reset(fstatement));
|
||||||
RowsAffected:=sqlite3_changes(fhandle);
|
RowsAffected:=sqlite3_changes(fhandle);
|
||||||
if (fstate=sqlite_row) then
|
if (fstate=sqlite_row) then
|
||||||
@ -399,6 +401,7 @@ var
|
|||||||
|
|
||||||
begin
|
begin
|
||||||
SC:=TSQLite3Cursor(cursor);
|
SC:=TSQLite3Cursor(cursor);
|
||||||
|
checkerror(sqlite3_reset(sc.fstatement));
|
||||||
If (AParams<>Nil) and (AParams.count > 0) then
|
If (AParams<>Nil) and (AParams.count > 0) then
|
||||||
SC.BindParams(AParams);
|
SC.BindParams(AParams);
|
||||||
SC.Execute;
|
SC.Execute;
|
||||||
@ -639,12 +642,6 @@ begin
|
|||||||
result:= 0;
|
result:= 0;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function TSQLite3Connection.stringquery(const asql: string): TStringArray;
|
|
||||||
begin
|
|
||||||
SetLength(result,0);
|
|
||||||
CheckError(sqlite3_exec(fhandle,pchar(asql),@execcallback,@result,nil));
|
|
||||||
end;
|
|
||||||
|
|
||||||
function execscallback(adata: pointer; ncols: longint; //adata = PArrayStringArray
|
function execscallback(adata: pointer; ncols: longint; //adata = PArrayStringArray
|
||||||
avalues: PPchar; anames: PPchar):longint; cdecl;
|
avalues: PPchar; anames: PPchar):longint; cdecl;
|
||||||
var
|
var
|
||||||
@ -656,7 +653,7 @@ begin
|
|||||||
PP:=PArrayStringArray(adata);
|
PP:=PArrayStringArray(adata);
|
||||||
N:=high(PP^); // Length-1;
|
N:=high(PP^); // Length-1;
|
||||||
setlength(PP^,N+2); // increase with 1;
|
setlength(PP^,N+2); // increase with 1;
|
||||||
p:= @(PP^[N]); // newly added array, fill with data.
|
p:= @(PP^[N+1]); // newly added array, fill with data.
|
||||||
setlength(p^,ncols);
|
setlength(p^,ncols);
|
||||||
for i:= 0 to ncols - 1 do
|
for i:= 0 to ncols - 1 do
|
||||||
p^[i]:= strPas(avalues[i]);
|
p^[i]:= strPas(avalues[i]);
|
||||||
@ -719,8 +716,13 @@ begin
|
|||||||
result := inherited StrToStatementType(s);
|
result := inherited StrToStatementType(s);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TSQLite3Connection.UpdateIndexDefs(var IndexDefs: TIndexDefs;
|
constructor TSQLite3Connection.Create(AOwner: TComponent);
|
||||||
const TableName: string);
|
begin
|
||||||
|
inherited Create(AOwner);
|
||||||
|
FConnOptions := FConnOptions + [sqEscapeRepeat] + [sqEscapeSlash] + [sqQuoteFieldnames];
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TSQLite3Connection.UpdateIndexDefs(IndexDefs: TIndexDefs; TableName: string);
|
||||||
var
|
var
|
||||||
str1: string;
|
str1: string;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user