You are not logged in.
Pages: 1
Hi AB i found a litte BUG in NewStatementPrepared:
see the line with // itSDS
function TSQLDBConnection.NewStatementPrepared(const aSQL: RawUTF8;
ExpectResults, RaiseExceptionOnError, AllowReconnect: Boolean): ISQLDBStatement;
var Stmt: TSQLDBStatement;
ToCache: boolean;
ndx,altern: integer;
cachedSQL: RawUTF8;
procedure TryPrepare(doraise: boolean);
var Stmt: TSQLDBStatement;
begin
Stmt := nil;
try
InternalProcess(speActive);
try
Stmt := NewStatement;
Stmt.Prepare(aSQL,ExpectResults);
if ToCache then begin
if fCache=nil then
fCache := TRawUTF8List.Create([fObjectsOwned,fNoDuplicate,fCaseSensitive]);
if fCache.AddObject(aSQL,Stmt)>=0 then // itSDS
Stmt._AddRef else // will be owned by fCache.Objects[]
SynDBLog.Add.Log(sllWarning,'NewStatementPrepared: unexpected '+
'cache duplicate for %',[Stmt.SQLWithInlinedParams],self);
end;
result := Stmt;
finally
InternalProcess(speNonActive);
end;
except
on E: Exception do begin
with SynDBLog.Add do
if [sllSQL,sllDB,sllException,sllError]*Family.Level<>[] then
LogLines(sllSQL,pointer(Stmt.SQLWithInlinedParams),self,'--');
Stmt.Free;
result := nil;
StringToUTF8(E.Message,fErrorMessage);
fErrorException := PPointer(E)^;
if doraise then
raise;
end;
end;
end;
the former used cachedSQL - Value is sometimes empty
Rad Studio 12.1 Santorini
Offline
You are right: there was a problem here!
But your fix won't handle SQL collisions and multiple prepared statements generation (i.e. use another prepared statement if it is already in use).
I guess the correct fix may be https://synopse.info/fossil/info/ac5dc8e082
The multiple preparation of statements has now a specific parameter in properties, and is disabled and logged by default: the ISQLDBStatement instance should be released ASAP.
Offline
Pages: 1