OLD | NEW |
1 <h1 align="center">SQLite Source Repository</h1> | 1 <h1 align="center">SQLite Source Repository</h1> |
2 | 2 |
3 This repository contains the complete source code for the SQLite database | 3 This repository contains the complete source code for the SQLite database |
4 engine. Some test scripts are also include. However, many other test scripts | 4 engine. Some test scripts are also include. However, many other test scripts |
5 and most of the documentation are managed separately. | 5 and most of the documentation are managed separately. |
6 | 6 |
| 7 If you are reading this on a Git mirror someplace, you are doing it wrong. |
| 8 The [official repository](https://www.sqlite.org/src/) is better. Go there |
| 9 now. |
| 10 |
7 ## Compiling | 11 ## Compiling |
8 | 12 |
9 First create a directory in which to place | 13 First create a directory in which to place |
10 the build products. It is recommended, but not required, that the | 14 the build products. It is recommended, but not required, that the |
11 build directory be separate from the source directory. Cd into the | 15 build directory be separate from the source directory. Cd into the |
12 build directory and then from the build directory run the configure | 16 build directory and then from the build directory run the configure |
13 script found at the root of the source tree. Then run "make". | 17 script found at the root of the source tree. Then run "make". |
14 | 18 |
15 For example: | 19 For example: |
16 | 20 |
(...skipping 29 matching lines...) Expand all Loading... |
46 nmake /f Makefile.msc sqlite3.dll TOP=..\sqlite | 50 nmake /f Makefile.msc sqlite3.dll TOP=..\sqlite |
47 nmake /f Makefile.msc sqlite3.exe TOP=..\sqlite | 51 nmake /f Makefile.msc sqlite3.exe TOP=..\sqlite |
48 nmake /f Makefile.msc test TOP=..\sqlite | 52 nmake /f Makefile.msc test TOP=..\sqlite |
49 | 53 |
50 There are several build options that can be set via the NMAKE command | 54 There are several build options that can be set via the NMAKE command |
51 line. For example, to build for WinRT, simply add "FOR_WINRT=1" argument | 55 line. For example, to build for WinRT, simply add "FOR_WINRT=1" argument |
52 to the "sqlite3.dll" command line above. When debugging into the SQLite | 56 to the "sqlite3.dll" command line above. When debugging into the SQLite |
53 code, adding the "DEBUG=1" argument to one of the above command lines is | 57 code, adding the "DEBUG=1" argument to one of the above command lines is |
54 recommended. | 58 recommended. |
55 | 59 |
56 SQLite does not require Tcl to run, but a Tcl installation is required | 60 SQLite does not require [Tcl](http://www.tcl.tk/) to run, but a Tcl installation |
57 by the makefiles (including those for MSVC). SQLite contains a lot of | 61 is required by the makefiles (including those for MSVC). SQLite contains |
58 generated code and Tcl is used to do much of that code generation. The | 62 a lot of generated code and Tcl is used to do much of that code generation. |
59 makefiles also require AWK. | 63 The makefiles also require AWK. |
60 | 64 |
61 ## Source Code Tour | 65 ## Source Code Tour |
62 | 66 |
63 Most of the core source files are in the **src/** subdirectory. But | 67 Most of the core source files are in the **src/** subdirectory. But |
64 src/ also contains files used to build the "testfixture" test harness; | 68 src/ also contains files used to build the "testfixture" test harness; |
65 those file all begin with "test". And src/ contains the "shell.c" file | 69 those file all begin with "test". And src/ contains the "shell.c" file |
66 which is the main program for the "sqlite3.exe" command-line shell and | 70 which is the main program for the "sqlite3.exe" command-line shell and |
67 the "tclsqlite.c" file which implements the bindings to SQLite from the | 71 the "tclsqlite.c" file which implements the bindings to SQLite from the |
68 Tcl programming language. (Historical note: SQLite began as a Tcl | 72 Tcl programming language. (Historical note: SQLite began as a Tcl |
69 extension and only later escaped to the wild as an independent library.) | 73 extension and only later escaped to the wild as an independent library.) |
(...skipping 18 matching lines...) Expand all Loading... |
88 Several of the C-language source files used by SQLite are generated from | 92 Several of the C-language source files used by SQLite are generated from |
89 other sources rather than being typed in manually by a programmer. This | 93 other sources rather than being typed in manually by a programmer. This |
90 section will summarize those automatically-generated files. To create all | 94 section will summarize those automatically-generated files. To create all |
91 of the automatically-generated files, simply run "make target_source". | 95 of the automatically-generated files, simply run "make target_source". |
92 The "target_source" make target will create a subdirectory "tsrc/" and | 96 The "target_source" make target will create a subdirectory "tsrc/" and |
93 fill it with all the source files needed to build SQLite, both | 97 fill it with all the source files needed to build SQLite, both |
94 manually-edited files and automatically-generated files. | 98 manually-edited files and automatically-generated files. |
95 | 99 |
96 The SQLite interface is defined by the **sqlite3.h** header file, which is | 100 The SQLite interface is defined by the **sqlite3.h** header file, which is |
97 generated from src/sqlite.h.in, ./manifest.uuid, and ./VERSION. The | 101 generated from src/sqlite.h.in, ./manifest.uuid, and ./VERSION. The |
98 Tcl script at tool/mksqlite3h.tcl does the conversion. The manifest.uuid | 102 [Tcl script](http://www.tcl.tk) at tool/mksqlite3h.tcl does the conversion. |
99 file contains the SHA1 hash of the particular check-in and is used to generate | 103 The manifest.uuid file contains the SHA1 hash of the particular check-in |
100 the SQLITE_SOURCE_ID macro. The VERSION file contains the current SQLite | 104 and is used to generate the SQLITE\_SOURCE\_ID macro. The VERSION file |
101 version number. The sqlite3.h header is really just a copy of src/sqlite.h.in | 105 contains the current SQLite version number. The sqlite3.h header is really |
102 with the source-id and version number inserted at just the right spots. | 106 just a copy of src/sqlite.h.in with the source-id and version number inserted |
103 Note that comment text in the sqlite3.h file is used to generate much of | 107 at just the right spots. Note that comment text in the sqlite3.h file is |
104 the SQLite API documentation. The Tcl scripts used to generate that | 108 used to generate much of the SQLite API documentation. The Tcl scripts |
105 documentation are in a separate source repository. | 109 used to generate that documentation are in a separate source repository. |
106 | 110 |
107 The SQL language parser is **parse.c** which is generate from a grammar in | 111 The SQL language parser is **parse.c** which is generate from a grammar in |
108 the src/parse.y file. The conversion of "parse.y" into "parse.c" is done | 112 the src/parse.y file. The conversion of "parse.y" into "parse.c" is done |
109 by the [lemon](./doc/lemon.html) LALR(1) parser generator. The source code | 113 by the [lemon](./doc/lemon.html) LALR(1) parser generator. The source code |
110 for lemon is at tool/lemon.c. Lemon uses a | 114 for lemon is at tool/lemon.c. Lemon uses a |
111 template for generating its parser. A generic template is in tool/lempar.c, | 115 template for generating its parser. A generic template is in tool/lempar.c, |
112 but SQLite uses a slightly modified template found in src/lempar.c. | 116 but SQLite uses a slightly modified template found in src/lempar.c. |
113 | 117 |
114 Lemon also generates the **parse.h** header file, at the same time it | 118 Lemon also generates the **parse.h** header file, at the same time it |
115 generates parse.c. But the parse.h header file is | 119 generates parse.c. But the parse.h header file is |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
167 prepared statements, the description of | 171 prepared statements, the description of |
168 [how transactions work](http://www.sqlite.org/atomiccommit.html), and | 172 [how transactions work](http://www.sqlite.org/atomiccommit.html), and |
169 the [overview of the query planner](http://www.sqlite.org/optoverview.html). | 173 the [overview of the query planner](http://www.sqlite.org/optoverview.html). |
170 | 174 |
171 Unfortunately, years of effort have gone into optimizating SQLite, both | 175 Unfortunately, years of effort have gone into optimizating SQLite, both |
172 for small size and high performance. And optimizations tend to result in | 176 for small size and high performance. And optimizations tend to result in |
173 complex code. So there is a lot of complexity in the SQLite implementation. | 177 complex code. So there is a lot of complexity in the SQLite implementation. |
174 | 178 |
175 Key files: | 179 Key files: |
176 | 180 |
177 * **sqlite3.h** - This file defines the public interface to the SQLite | 181 * **sqlite.h.in** - This file defines the public interface to the SQLite |
178 library. Readers will need to be familiar with this interface before | 182 library. Readers will need to be familiar with this interface before |
179 trying to understand how the library works internally. | 183 trying to understand how the library works internally. |
180 | 184 |
181 * **sqliteInt.h** - this header file defines many of the data objects | 185 * **sqliteInt.h** - this header file defines many of the data objects |
182 used internally by SQLite. | 186 used internally by SQLite. |
183 | 187 |
184 * **parse.y** - This file describes the LALR(1) grammer that SQLite uses | 188 * **parse.y** - This file describes the LALR(1) grammer that SQLite uses |
185 to parse SQL statements, and the actions that are taken at each stop | 189 to parse SQL statements, and the actions that are taken at each step |
186 in the parsing process. | 190 in the parsing process. |
187 | 191 |
188 * **vdbe.c** - This file implements the virtual machine that runs | 192 * **vdbe.c** - This file implements the virtual machine that runs |
189 prepared statements. There are various helper files whose names | 193 prepared statements. There are various helper files whose names |
190 begin with "vdbe". The VDBE has access to the vdbeInt.h header file | 194 begin with "vdbe". The VDBE has access to the vdbeInt.h header file |
191 which defines internal data objects. The rest of SQLite interacts | 195 which defines internal data objects. The rest of SQLite interacts |
192 with the VDBE through an interface defined by vdbe.h. | 196 with the VDBE through an interface defined by vdbe.h. |
193 | 197 |
194 * **where.c** - This file analyzes the WHERE clause and generates | 198 * **where.c** - This file analyzes the WHERE clause and generates |
195 virtual machine code to run queries efficiently. This file is | 199 virtual machine code to run queries efficiently. This file is |
196 sometimes called the "query optimizer". It has its own private | 200 sometimes called the "query optimizer". It has its own private |
197 header file, whereInt.h, that defines data objects used internally. | 201 header file, whereInt.h, that defines data objects used internally. |
198 | 202 |
199 * **btree.c** - This file contains the implementation of the B-Tree | 203 * **btree.c** - This file contains the implementation of the B-Tree |
200 storage engine used by SQLite. | 204 storage engine used by SQLite. |
201 | 205 |
202 * **pager.c** - This file contains the "pager" implementation, the | 206 * **pager.c** - This file contains the "pager" implementation, the |
203 module that implements transactions. | 207 module that implements transactions. |
204 | 208 |
205 * **os_unix.c** and **os_win.c** - These two files implement the interface | 209 * **os_unix.c** and **os_win.c** - These two files implement the interface |
206 between SQLite and the underlying operating system using the run-time | 210 between SQLite and the underlying operating system using the run-time |
207 pluggable VFS interface. | 211 pluggable VFS interface. |
208 | 212 |
| 213 * **shell.c** - This file is not part of the core SQLite library. This |
| 214 is the file that, when linked against sqlite3.a, generates the |
| 215 "sqlite3.exe" command-line shell. |
| 216 |
| 217 * **tclsqlite.c** - This file implements the Tcl bindings for SQLite. It |
| 218 is not part of the core SQLite library. But as most of the tests in this |
| 219 repository are written in Tcl, the Tcl language bindings are important. |
| 220 |
| 221 There are many other source files. Each has a suscinct header comment that |
| 222 describes its purpose and role within the larger system. |
| 223 |
209 | 224 |
210 ## Contacts | 225 ## Contacts |
211 | 226 |
212 The main SQLite webpage is [http://www.sqlite.org/](http://www.sqlite.org/) | 227 The main SQLite webpage is [http://www.sqlite.org/](http://www.sqlite.org/) |
213 with geographically distributed backup servers at | 228 with geographically distributed backup servers at |
214 [http://www2.sqlite.org/](http://www2.sqlite.org) and | 229 [http://www2.sqlite.org/](http://www2.sqlite.org) and |
215 [http://www3.sqlite.org/](http://www3.sqlite.org). | 230 [http://www3.sqlite.org/](http://www3.sqlite.org). |
OLD | NEW |