0

I switched from using custom Sqlite3 wrapper to System.Sqlite unit from Delphi XE3.

So far I am happy with the outcome but I am not 100% sure if I should still call

...
initialization

  sqlite3_initialize;

finalization

  sqlite3_shutdown;
end.

in my code?

I guess the real question is

Is sqlite3.c is compiled with SQLITE_OMIT_AUTOINIT defined in the Windows 3.7.17 distribution available for download at http://www.sqlite.org/download.html ?

Gad D Lord
  • 6,620
  • 12
  • 60
  • 106
  • I'd think you could comment it out of your code and find out pretty quickly. :-) – Ken White May 24 '13 at 22:00
  • If I comment it - it simply works. But yet I have to be sure. Is there an API call to check the compile time options. – Gad D Lord May 24 '13 at 22:29
  • Execute [`PRAGMA compile_options;`](http://www.sqlite.org/pragma.html#pragma_compile_options). – CL. May 25 '13 at 07:27
  • As an alternative, you might consider to [`get FireDAC`](http://cc.embarcadero.com/item/29318) if you're having Enterprise, Ultimate or Architect edition of Delphi or RAD Studio. – TLama May 26 '13 at 07:46
  • @TLama Do not forget there are several *free* alternatives around. But FireDac will probably be more supported than the previous code from "pure" Embarcadero. – Arnaud Bouchez May 28 '13 at 11:04

1 Answers1

4

The official documentation states:

SQLITE_OMIT_AUTOINIT

For backwards compatibility with older versions of SQLite that lack the sqlite3_initialize() interface, the sqlite3_initialize() interface is called automatically upon entry to certain key interfaces such as sqlite3_open(), sqlite3_vfs_register(), and sqlite3_mprintf(). The overhead of invoking sqlite3_initialize() automatically in this way may be omitted by building SQLite with the SQLITE_OMIT_AUTOINIT C-preprocessor macro. When built using SQLITE_OMIT_AUTOINIT, SQLite will not automatically initialize itself and the application is required to invoke sqlite3_initialize() directly prior to beginning use of the SQLite library.

Therefore:

  • By default, this conditional is not defined;
  • You can define it if you are sure that sqlite3_initialize() is called;
  • It does not cost anything about performance to run sqlite3_initialize() or not, since initialization check will be performed on "upon entry to certain key interfaces", i.e. at opening the DB.

The fact that everything works even if sqlite3_initialize() is not called clearly shows it.

In our SQLite3 wrapper (allowing static or external linking), we enable this conditional, since we explicitly call sqlite3_initialize(). But in the official dll, this conditional is not defined.

Arnaud Bouchez
  • 42,305
  • 3
  • 71
  • 159