You are not logged in.
After performing TSQLRestServerDB.Backup, the server could not execute any SQL anymore.
Error:
ESQLite3Exception ("TSQLRequest.Reset called with no previous Request") at 00328938 SynSQLite3.TSQLRequest.Reset (4127) stack trace API 0029F900 SynCommons.SynRtlUnwind (37997) 00009790 System.@HandleOnException (18403)
To solve this problem, we need to add fStatementCache.Init(DB.DB); after opening DB.
function TSQLRestServerDB.Backup(Dest: TStream): boolean;
{$ifdef CPU64} // currently not working on Win64 - never mind
begin
result := false;
end;
{$else}
var Source: TFileStream;
Closed: boolean;
user_version: cardinal;
begin
result := false;
if (Self=nil) or (DB=nil) then
exit;
fStatementCache.ReleaseAllDBStatements;
user_version := DB.user_version;
DB.LockAndFlushCache;
try
try
// perform a VACCUM to recreate the database content
EngineExecute('VACUUM');
Closed := false;
try
Closed := DB.DBClose=SQLITE_OK;
// compress the database content file
Source := TFileStream.Create(DB.FileName,fmOpenRead or fmShareDenyNone);
try
Dest.CopyFrom(Source,0); // Count=0 for whole stream copy
result := true;
finally
Source.Free;
end;
finally
if Closed then begin
DB.DBOpen; // reopen the database if was previously closed
fStatementCache.Init(DB.DB); // <-- NEED TO ADD THIS
FreeAndNil(fRegisteredVirtualTableModules); // force register modules
InitializeEngine; // register functions and modules
CreateMissingTables(user_version); // register virtual tables
end;
end;
finally
DB.UnLock;
end;
except
on E: Exception do
result := false;
end;
end;
{$endif}
Offline
Should I create a ticket?
Offline