Skip to content
Permalink
Browse files

small refactoring of the TSQLDBStatement*.Reset methods

  • Loading branch information
Arnaud Bouchez
Arnaud Bouchez committed Mar 21, 2020
1 parent 983a6a3 commit 394e40c64e960cd28422e0084924f73434e9d551
Showing with 18 additions and 18 deletions.
  1. +1 −1 SynDB.pas
  2. +2 −1 SynDBDataset.pas
  3. +2 −3 SynDBFirebird.pas
  4. +6 −6 SynDBODBC.pas
  5. +2 −2 SynDBPostgres.pas
  6. +1 −1 SynDBSQLite3.pas
  7. +2 −2 SynDBZeos.pas
  8. +1 −1 SynOleDB.pas
  9. +1 −1 SynopseCommit.inc
@@ -7795,9 +7795,9 @@ procedure TSQLDBStatementWithParams.BindFromRows(Rows: TSQLDBStatement);

procedure TSQLDBStatementWithParams.Reset;
begin
inherited Reset;
fParam.Clear;
fParamsArrayCount := 0;
inherited Reset;
end;


@@ -447,7 +447,8 @@ function TSQLDBDatasetStatementAbstract.Step(SeekFirst: boolean): boolean;

procedure TSQLDBDatasetStatementAbstract.Reset;
begin
fQuery.Close;
if (fQuery<>nil) and fQuery.Active then
fQuery.Close;
inherited Reset;
end;

@@ -864,12 +864,11 @@ function TSQLDBFirebirdStatement.Step(SeekFirst: boolean): boolean;
procedure TSQLDBFirebirdStatement.Reset;
begin
ReleaseMainStatementIfAny; // global transaction context may have changed
inherited Reset;
with TFirebirdLib(TSQLDBFirebirdConnection(fConnection).fFirebirdInstance) do begin
with TFirebirdLib(TSQLDBFirebirdConnection(fConnection).fFirebirdInstance) do
if fExpectResults and (fCurrent<>nil) then
// release opened cursor for queries
Check(isc_dsql_free_statement(fStatus,fCurrent.Statement,DSQL_close),fStatus);
end;
inherited Reset;
end;


@@ -1827,12 +1827,12 @@ procedure TODBCStatement.ExecutePrepared;
procedure TODBCStatement.Reset;
begin
if fStatement<>nil then
with ODBC do begin
if fColumnCount>0 then
Check(nil,self,CloseCursor(fStatement),SQL_HANDLE_STMT,fStatement);
if fParamCount>0 then
Check(nil,self,FreeStmt(fStatement,SQL_RESET_PARAMS),SQL_HANDLE_STMT,fStatement);
end;
with ODBC do begin
if fColumnCount>0 then
Check(nil,self,CloseCursor(fStatement),SQL_HANDLE_STMT,fStatement);
if fParamCount>0 then
Check(nil,self,FreeStmt(fStatement,SQL_RESET_PARAMS),SQL_HANDLE_STMT,fStatement);
end;
inherited Reset;
end;

@@ -10,6 +10,7 @@
Features:
- fast, minimum memory allocation
- includes its own simple wrapper to the libpq native client
- perfect fit for our ORM (JSON results, bulk insert/update/delete)
- array binding for select statements (caller should use =ANY(?) etc.)
Limitations:
@@ -403,8 +404,7 @@ constructor TSQLDBPostgresLib.Create;
begin
FreeLibrary(fHandle);
fHandle := 0;
raise ESQLDBPostgres.CreateUTF8('Invalid %: missing % - should be 8.3+',
[LIBNAME, PQ_ENTRIES[i]]);
raise ESQLDBPostgres.CreateUTF8('Invalid %: missing %', [LIBNAME, PQ_ENTRIES[i]]);
end;
inc(P);
end;
@@ -734,10 +734,10 @@ procedure TSQLDBSQLite3Statement.Prepare(const aSQL: RawUTF8;

procedure TSQLDBSQLite3Statement.Reset;
begin
inherited Reset;
fStatement.Reset;
fUpdateCount := 0;
// fStatement.BindReset; // slow down the process, and is not mandatory
inherited Reset;
end;

function TSQLDBSQLite3Statement.Step(SeekFirst: boolean): boolean;
@@ -1029,7 +1029,7 @@ procedure TSQLDBZEOSStatement.ExecutePrepared;
{$endif}
for i := 0 to fParamCount-1 do
with fParams[i] do begin
if (Length(VArray)>0) and (fConnection.Properties.DBMS = dPostgreSQL) then begin
if (Length(VArray)>0) and (fConnection.Properties.DBMS=dPostgreSQL) then begin
if VType in [ftInt64,ftCurrency,ftDouble,ftUTF8] then
VData := BoundArrayToJSONArray(VArray) else
raise ESQLDBZEOS.CreateUTF8('%.ExecutePrepared: Invalid array type % ' +
@@ -1105,7 +1105,7 @@ procedure TSQLDBZEOSStatement.Reset;
if fResultSet<>nil then begin
fResultInfo := nil;
{$ifndef ZEOS72UP}
fResultSet := nil; //commenting this makes it possible to seek cursor pos to 0 and use the interface again -> e.g. ReadOneByOneRate
fResultSet := nil;
{$ENDIF}
end;
if fStatement<>nil then
@@ -2079,7 +2079,6 @@ procedure TOleDBStatement.CloseRowSet;

procedure TOleDBStatement.Reset;
begin
inherited Reset;
if fParamCount>0 then begin
fParam.Clear;
Finalize(fParamBindings);
@@ -2094,6 +2093,7 @@ procedure TOleDBStatement.Reset;
Prepare(fSQL,fExpectResults);
end;
fUpdateCount := 0;
inherited Reset;
end;

function TOleDBStatement.UpdateCount: integer;
@@ -1 +1 @@
'1.18.5870'
'1.18.5871'

0 comments on commit 394e40c

Please sign in to comment.
You can’t perform that action at this time.