Hi

I wanted to use the SQLite error logging documented here...

http://www.sqlite.org/errlog.html

But I found that the implementation in SQLite is odd: when
defining SQLITE_ENABLE_SQLLOG, SQLite calls
a function sqlite3_init_sqllog() inside sqlite3_initialize().
That function sqlite3_init_sqllog() is not defined in SQLite
itself and has to be defined by the application.

This is not nice, as it causes a circular dependency
between the application which calls SQLite API, and
SQLite itself which calls sqlite3_init_sqllog() defined
in the application.

Why wasn't a callback used instead?  In fact, there is
such a callback which can be registered when the application
calls sqlite3_config(SQLITE_CONFIG_LOG, &callback, ...).

So why does SQLite impose that the application defines
sqlite3_init_sqllog()?  Even trying to compile and link the
SQLite standard shell.c with -DSQLITE_ENABLE_SQLLOG
fails without defining a sqlite3_init_sqllog() function.

In my build, I create a library for SQLite.  Several programs
link with that SQLite lib. If I define SQLITE_ENABLE_SQLLOG,
it breaks the build as sqlite3_init_sqllog() is undefined.
I can define it of course define it but I have to fix all programs
(a pain). Also when linking with the SQLite lib, I still get link errors
anyway because of the circular dependencies it introduces
between libraries. When linking, libraries should be given
to ld in order, from the general one to the low level one. But
that assumes no circular dependencies between libraries.

To fix it, why not simply remove the following lines from sqlite3.c
in sqlite3_initialize()?

  {
    extern void sqlite3_init_sqllog(void);
    sqlite3_init_sqllog();
  }

... and let the application register the logging callback with
something like:

  if (sqlite3_config(SQLITE_CONFIG_LOG, &SqliteErrorCallback, NULL) !=
SQLITE_OK)
  {
    ...
  }

I've done that. It looks OK, but am I missing something?
I also think that this should be done by default in SQLite.

Regards
Dominique

PS: I'm using SQLite-3.8.2.
_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to