1. Executive Summary

submited by
Style Pass
2021-06-13 04:30:05

Over 100 separate source files are concatenated into a single large files of C-code named "sqlite3.c" and called "the amalgamation". The amalgamation contains everything an application needs to embed SQLite. The amalgamation file is more than 220,000 lines long and over 7.5 megabytes in size (as of 2018-11-24).

Combining all the code for SQLite into one big file makes SQLite easier to deploy — there is just one file to keep track of. And because all code is in a single translation unit, compilers can do better inter-procedure optimization resulting in machine code that is between 5% and 10% faster.

The SQLite library consists of 102 files of C code (as of Version 3.9.0 - 2015-10-14) in the core with 32 additional files that implement the FTS3, FTS5, RTREE, DBSTAT, JSON1, and RBU extensions. Of the 102 main source files, about 75% are C code and about 25% are C header files. Most of these are "source" files in the sense that they are stored in the SQLite version control system and are edited manually in an ordinary text editor. But some of the C-language files are generated using scripts or auxiliary programs. For example, the parse.y file contains an LALR(1) grammar of the SQL language which is compiled down into are parser in files "parse.c" and "parse.h" by the Lemon parser generator.

The makefiles for SQLite have an "sqlite3.c" target for building the file we call "the amalgamation". The amalgamation is a single C code file, named "sqlite3.c", that contains all C code for the core SQLite library and the FTS3, FTS5, RTREE, DBSTAT, JSON1, and RBU extensions. This file contains about 184K lines of code (113K if you omit blank lines and comments) and is over 6.4 megabytes in size. Though the various extensions are included in the "sqlite3.c" amalgamation file, they are disabled using #ifdef statements. Activate the extensions using compile-time options like:

Leave a Comment