Results from callcatcher run on SQLite
(1) By Dan Shearer (danshearer) on 2020-09-25 09:20:54 [link] [source]
While learning how debugging works under SQLite, I briefly wondered if there might be lots of unused code. There isn't, but to check I ran callcatcher on trunk, and that might be interesting to others.
callcatcher reports 4 unused functions, which although correct doesn't mean they can all be removed:
export CC="callcatcher gcc"
export AR="callarchive ar"
./configure && make
Ignoring calls in test*c, look at the code I see:
ext/misc/memtrace.c:sqlite3MemTraceDeactivate() is not called regardless of SQLITE_DEBUG, although I don't yet understand memory tracing. So maybe it can be removed.
main.c/sqlite3_global_recover() is unused. loadext.c has a comment saying sqlite3_global_recover() is deprecated, but I see it isn't in the public SQLite interface. I think it can be removed.
malloc.c/sqlite3_memory_alarm() is unused, however it is an SQLITE_DEPRECATED function in the public interface in sqlite.h.in. This means it cannot be removed.
main.c/sqlite3_shutdown() is almost unused. It is discussed in comments, and if -DTCLSH is specified, it is called at the end of tclsqlite.c, but I can't see why it is specially needed there. So it can probably be removed?
(2) By anonymous on 2020-09-27 18:41:59 in reply to 1 [link] [source]
sqlite3_shutdown() might be needed in some programs (such as if you need to reconfigure SQLite, or if you need to continue running the program after you are finished with SQLite and want to deallocate some resources), although most programs probably do not need it. The other functions you mentioned I think are obsolete and do not do anything useful anyways (they might have been needed in very old versions; I don't know). If I am wrong about any of this, then hopefully someone else will write another message with the correct information.
(3) By Dan Shearer (danshearer) on 2020-09-29 16:38:39 in reply to 1 [link] [source]
I had overlooked this:
around sqlite3_global_recover(). So that presumably is the careful SQLite way for code to quietly grow old and die, just enclose it in OMIT_DEPRECATED and wait for a few years.
(4) By Richard Hipp (drh) on 2020-09-29 17:35:08 in reply to 3 [source]
... wait for a few years
Or decades. Same idea.