#1 mORMot 1 » SynSQLite3.pas - is it MacOS ready » 2012-11-14 14:25:10

gaddlord
Replies: 1

I see references to Winapi.Windows.pas file.

Is it possible to use SynSQLite3 in a Fire Monkey application?

#2 Re: mORMot 1 » Any idea why memory leak is reported » 2012-01-13 00:17:21

Please disregard. It turned out to be a dummy error in my code which had oveload instead of override in my custom Reader destructor which never got called and finalization of statements never executed.

My bad.

#3 Re: mORMot 1 » Any idea why memory leak is reported » 2012-01-08 18:04:04

The code snippet was added exactly in the SynSQLite3.pas unit.

I added this there to show case how to achieve this.

A chopped down to the bare minimum version which demostrates the issue is available at http://dl.dropbox.com/u/3607590/TestSynSQLiteLeak.zip

Seems that 23 malloc Pointers are not having their Free functions called.

Can this be related to a known "pseudo leak" from the past as described here http://old.nabble.com/memory-leak-on-sq … 29415.html?

#4 mORMot 1 » Any idea why memory leak is reported » 2012-01-08 16:14:39

gaddlord
Replies: 4

I have the following code

var
  C: TSQLDatabase;

initialization

  sqlite3_initialize; // so sqlite3.c is compiled with SQLITE_OMIT_AUTOINIT defined

  C := TSQLDatabase.Create('C:\database.db3');
  C.DBOpen;

finalization

  C.DBClose;
  FreeAndNil(C);

  sqlite3_shutdown;

at the end of SynSQLite3.pas

It generates:

--------------------------------2012/1/8 18:17:15--------------------------------
This application has leaked memory. The small block leaks are (excluding expected leaks registered by pointer):

21 - 36 bytes: Unknown x 6
37 - 52 bytes: Unknown x 4
53 - 68 bytes: Unknown x 3
69 - 84 bytes: Unknown x 3
85 - 100 bytes: Unknown x 3
485 - 532 bytes: Unknown x 2
1013 - 1124 bytes: Unknown x 1

for

This block was allocated by thread 0xE90, and the stack trace (return addresses) at the time was:
804AEA [System][@GetMem][34]
D0D61C [SynSQLite3.pas][SynSQLite3][@Synsqlite3_malloc][1934]
D108FF [SynSQLite3]
D11013 [SynSQLite3][@Synsqlite3_sqlite3_memory_highwater]
D1147B [SynSQLite3][@Synsqlite3_sqlite3_realloc]
D1143E [SynSQLite3][@Synsqlite3_sqlite3_realloc]
D3BB54 [SynSQLite3][@Synsqlite3_sqlite3_set_authorizer]
D55FC4 [SynSQLite3][@Synsqlite3_sqlite3_errmsg]
D560B8 [SynSQLite3][@Synsqlite3_sqlite3_open]
D0E17E [SynSQLite3.pas][SynSQLite3][TSQLDatabase.DBOpen][2677]
D0DC47 [SynSQLite3.pas][SynSQLite3][TSQLDatabase.$bctr][2394]

Any idea why this happens?

#5 mORMot 1 » Fix the comments to be in DocType format with /// prefix » 2012-01-07 23:14:23

gaddlord
Replies: 2

All existing comments are in

{{ ... }} form where they should be in

/// ...
/// ...

form.

Please fix those in order to have nice integrated help suggestions when using latest versions of Delphi.

for example this

{{ Prepare a UTF-8 encoded SQL statement
   - compile the SQL into byte-code
   - parameters ? ?NNN :VV @VV $VV can be bound with Bind*() functions below
   - raise an ESQLException on any error }
function Prepare(DB: TSQLite3DB; const SQL: RawUTF8): integer;

should become

/// <summary>
/// Prepare a UTF-8 encoded SQL statement
/// compile the SQL into byte-code
/// parameters ? ?NNN :VV @VV $VV can be bound with Bind*() functions below
/// </summary>
/// <param name="DB"></param>
/// <param name="SQL"></param>
/// <returns></returns>
/// <exception cref="ESQLException">raise an ESQLException on any error</exception>
function Prepare(DB: TSQLite3DB; const SQL: RawUTF8): integer;

#6 mORMot 1 » Why TSQLRequest = object? This is arcane. » 2012-01-07 23:05:29

gaddlord
Replies: 2

I wonder why you chose to declare

TSQLRequest = object
TSQLStatementCached = object

this is arcane Object Pascal way of declaring stuff. And it can create issues as well (see http://stackoverflow.com/questions/1013 … bject-type for example).

Can you convert those to

TSQLRequest = class(TObject)
TSQLStatementCached = class(TObject)

this would allow easier control of declaration, feeing, avoid the need to use pointers in the cache, and allow you building (as in my case) global cache for binded statements (not just Json results).

#7 mORMot 1 » Improve SynSQLite3 with transactions DEFERRED, IMMEDIATE, EXCLUSIVE » 2012-01-02 14:56:52

gaddlord
Replies: 1

I miss the ability to specify what is the transaction type.

I suggest we add:

type
  TTransactionBehaviour = (
    tbDeferred,
    tbImmediate,
    tbExclusive);
const
  TTransactionBehaviourTokens: array[TTransactionBehaviour] of string = (
    'DEFERRED', 'IMMEDIATE', 'EXCLUSIVE');

and modify BeginTransaction to:


procedure TSQLDataBase.TransactionBegin(const Behaviour: TTransactionBehaviour = tbDeferred);
begin
  if self=nil then
    exit; // avoid GPF in case of call from a static-only server
  if fTransactionActive then begin
    Execute('ROLLBACK TRANSACTION;');
    fTransactionActive := false;
  end;
  Execute('BEGIN ' + TTransactionBehaviourTokens[Behaviour] + ' TRANSACTION;');
  fTransactionActive := true;
end;

Can you include this in the next version or give me access to patch it myself in SVN?

#8 mORMot 1 » Improve SynSQLite3 with sqlite3_trace and sqlite3_changes » 2012-01-02 14:54:36

gaddlord
Replies: 1

I would like to make some suggestions on how to improve SQLite3 support.

I would like to see those definitions added:


type
  TSQLite3TraceCallback = procedure(TraceArg: Pointer; Trace: PUTF8Char);

function sqlite3_trace(aDb: TSQLite3Db; aCallback: TSQLite3TraceCallback;
  aUserData: Pointer): Pointer; {$ifndef USEFASTCALL}cdecl;{$endif} external;

function sqlite3_changes(aDb: TSQLite3Db): Integer;
  {$ifndef USEFASTCALL}cdecl;{$endif} external;

I use SQLite3.obj compiled with trace switched on and I miss the sqlite3_trace being declared.

I also miss the sqlite3_changes function.

Can you include those in the next release?

I am also interested on how I can contribute by commiting those changes myself? I am quite new to Open Source and do not know where to commit to - a branch, the trunk, send you a patch file over email?

Board footer

Powered by FluxBB