SQLITE版本3.7.15.1中的sqlite3.c长达13万多行,要细致分析这个文件可不容易。但是,这个文件是由许多个.H和.C文件组合而成,正如此文件开始的注释中所述:
/******************************************************************************
** This file is an amalgamation of many separate C source files from SQLite
** version 3.7.15.1. By combining all the individual C code files into this
** single large file, the entire code can be compiled as a single translation
** unit. This allows many compilers to do optimizations that would not be
** possible if the files were compiled separately. Performance improvements
** of 5% or more are commonly seen when SQLite is compiled as a single
** translation unit.
**
** This file is all you need to compile SQLite. To use SQLite in other
** programs, you need this file and the "sqlite3.h" header file that defines
** the programming interface to the SQLite library. (If you do not have
** the "sqlite3.h" header file at hand, you will find a copy embedded within
** the text of this file. Search for "Begin file sqlite3.h" to find the start
** of the embedded sqlite3.h header file.) Additional code files may be needed
** if you want a wrapper to interface SQLite with your choice of programming
** language. The code for the "sqlite3" command-line shell is also in a
** separate file. This file contains only code for the core SQLite library.
*/
另外,从上述注释中,我们也可以清楚sqlite3.h和另一个一起发布的头文件sqlite3ext.h(此文件一般不必使用)如何使用了。
下面给出我对这个长文件结构的简要分析记录一,供有共同研究的爱好者参考。
其中,已经使用了相应的表示包含意义的缩进,相信我不必详细说明了吧。
Begin file sqliteInt.h (end at about line 12436)
Begin file sqliteLimit.h
Begin file sqlite3.h (at about 7161 lines)
Begin file hash.h (at about line 7755)
Begin file parse.h (at about line 7856)
Begin file btree.h
Begin file vdbe.h --Header file for the Virtual DataBase Engine, at about line 8644
Begin file opcodes.h
Begin file pager.h--The page cache subsystem reads and writes a file a page
at a time and
provides a journal for rollback.
Begin file pcache.h--defines the interface that the sqlite page cache
subsystem
Begin file os.h
Begin file mutex.h
Begin file global.c (at about line 12437)--contains definitions of global variables and contants
Begin file ctime.c (at about line 12668)
Begin file status.c (at about line 13075)
Begin file vdbeInt.h
Begin file date.c (at about line 13816)
Begin file os.c (at about line 14946)
Begin file fault.c(at about line 15304)
Begin file mem0.c
Begin file mem1.c
Begin file mem2.c
Begin file mem3.c
Begin file mem5.c (a bit strange without mem4.c???!!)
Begin file mutex.c--contains the C functions that implement mutexes
Begin file mutex_noop.c
Begin file mutex_unix.c
Begin file mutex_w32.c
Begin file malloc.c
Begin file printf.c
Begin file random.c
Begin file utf.c
Begin file util.c(at about line 21061)
Begin file hash.c
Begin file opcodes.c
Begin file os_unix.c
Begin file os_common.h
Begin file hwtime.h
Begin file os_win.c
Begin file os_common.h
Begin file hwtime.h
Begin file bitvec.c
Begin file pcache.c
Begin file pcache1.c
Begin file rowset.c
Begin file pager.c(at about line 37203)
Begin file wal.h--defines the interface to the write-ahead logging system
Begin file wal.c
Begin file btmutex.c
Begin file btreeInt.h
Begin file btree.c
Begin file backup.c
Begin file vdbemem.c
Begin file vdbeaux.c
Begin file vdbeapi.c
Begin file vdbetrace.c
Begin file vdbe.c
Begin file hwtime.h
Begin file vdbeblob.c
Begin file vdbesort.c
Begin file journal.c
Begin file memjournal.c
Begin file walker.c--routines used for walking the parser tree for an SQL statement
Begin file resolve.c
Begin file expr.c
Begin file alter.c
Begin file analyze.c
Begin file attach.c
Begin file auth.c--code used to implement the sqlite3_set_authorizer() API
Begin file build.c--contains C code routines that are called by the SQLite parser
when syntax rules are reduced
Begin file callback.c
Begin file delete.c
Begin file func.c
Begin file fkey.c
Begin file insert.c
Begin file legacy.c
Begin file loadext.c--code used to dynamically load extensions into
the SQLite library
Begin file sqlite3ext.h(at about line 90707)
Begin file pragma.c--contains code used to implement the PRAGMA command
Begin file prepare.c
Begin file select.c
Begin file table.c
Begin file trigger.c
Begin file update.c
Begin file vacuum.c
Begin file vtab.c
Begin file where.c
Begin file parse.c
Begin file tokenize.c
Begin file keywordhash.h******************
Begin file complete.c
Begin file main.c--- Main file for the SQLite library
Begin file fts3.h
Begin file rtree.h
Begin file sqliteicu.h
Begin file notify.c
Begin file fts3.c
Begin file fts3Int.h
Begin file fts3_tokenizer.h
Begin file fts3_hash.h
Begin file fts3_aux.c
Begin file fts3_expr.c
Begin file fts3_hash.c
Begin file fts3_porter.c
Begin file fts3_tokenizer.c
Begin file fts3_tokenizer1.c
Begin file fts3_write.c
Begin file fts3_snippet.c
Begin file fts3_unicode.c
Begin file fts3_unicode2.c
Begin file rtree.c
Begin file icu.c
Begin file fts3_icu.c
/******about line 137441 ******** End of fts3_icu.c and whole file*/