Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | Add a better overview to fileio.in. |
---|---|
Downloads: | Tarball | ZIP archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA1: |
f0560b2aa44cf1b29a7a2bb16e8dbc29 |
User & Date: | dan 2008-07-30 09:00:39.000 |
Context
2008-07-30
| ||
18:30 | Add assumptions for "safe-append" and "atomic-write" VFS implementations. (check-in: 1276228968 user: dan tags: trunk) | |
09:00 | Add a better overview to fileio.in. (check-in: f0560b2aa4 user: dan tags: trunk) | |
2008-07-29
| ||
16:42 | Add definitions for the "atomic-write" "safe-append" and "sequential-write" VFS properties to fileio.html. (check-in: 26da8bcd0b user: dan tags: trunk) | |
Changes
Changes to pages/fileio.in.
︙ | ︙ | |||
59 60 61 62 63 64 65 | table of contents, figure numbering and internal references (section numbers and hyper-links. </b> </div> <!-- End of standard rt docs header --> <h1>Document Overview</h1> | | | > | | < < < < | < | < | | | | | | > | | > > > > | > > > > > | > > > > > > > > | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > < < < < < < < < < < < < < < > > | 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 | table of contents, figure numbering and internal references (section numbers and hyper-links. </b> </div> <!-- End of standard rt docs header --> <h1>Document Overview</h1> <p> SQLite stores an entire database within a single file, the format of which is described in the <i>SQLite File Database File Format</i> document <cite>ff_sqlitert_requirements</cite>. Each database file is stored within a file system, presumably provided by the host operating system. Instead of interfacing with the operating system directly, the host application is required to supply an adaptor component that implements the <i>SQLite Virtual File System</i> interface (described in <cite>capi_sqlitert_requirements</cite>). The adaptor component is responsible for translating the calls made by SQLite to the <i>VFS</i> interface into calls to the file-system interface provided by the operating system. This arrangement is depicted in figure <cite>figure_vfs_role</cite>. <center><img src="images/fileformat/vfs_role.gif"> <p><i>Figure <span class=fig id=figure_vfs_role></span> - Virtual File System (VFS) Adaptor</i> </center> <p> Although it would be easy to design a system that uses the <i>VFS</i> interface to read and update the content of a database file stored within a file-system, there are several complicated issues that need to be addressed by such a system: <ol> <li><p>SQLite is required to <b>implement atomic and durable transactions</b> (the 'A' and 'D' from the ACID acronym), even if an application, operating system or power failure occurs midway through or shortly after updating a database file. <p>To implement atomic transactions in the face of potential application, operating system or power failures, database writers write a copy of those portions of the database file that they are going to modify into a second file, the <i>journal file</i>, before writing to the database file. If a failure does occur while modifying the database file, SQLite can reconstruct the original database (before the modifications were attempted) based on the contents of the <i>journal file</i>. <li><p>SQLite is required to <b>implement isolated transactions</b> (the 'I' from the ACID acronym). <p>This is done by using the file locking facililities provided by the VFS adaptor to serialize writers (write transactions) and preventing readers (read transactions) from accessing database files while writers are midway through updating them. <li><p>For performance reasons, it is advantageous to <b>minimize the quantity of data read and written</b> to and from the file-system. <p>As one might expect, the amount of data read from the database file is minimized by caching portions of the database file in main memory. Additionally, multiple updates to the database file that are part of the same <i>write transaction</i> may be cached in main memory and written to the file periodically, allowing for more efficient IO patterns and eliminating the redundant write operations that could take place if part of the database file is modified more than once within a single <i>write transaction</i>. </ol> <p class=todo> System requirement references for the above points. <p> This document describes in detail the way that SQLite uses the API provided by the VFS adaptor component to solve the problems and implement the strategies enumerated above. It also specifies the assumptions made about the properties of the system that the VFS adaptor provides access to. For example, specific assumptions about the extent of data corruption that may occur if a power failure occurs while a database file is being updated are presented in section <cite>fs_characteristics</cite>. <p> This document does not specify the details of the interface that must be implemented by the VFS adaptor component, that is left to <cite>capi_sqlitert_requirements</cite>. <h2>Document Organization</h2> <h2>Glossary</h2> <p class=todo> After this document is ready, make the vocabulary consistent and then add a glossary here. <h1>VFS Adaptor Related Assumptions</h1> <h2>SQLite File-System Usage </h2> <p> SQLite uses the file-system service made available via the <i>VFS adaptor</i> to create, read and modify three different types of files, as follows: <ul> <li> database files, <li> journal files, and <li> master journal files. </ul> <p> A database file is a file-system file used to store an SQLite database image (see <cite>ff_sqlitert_requirements</cite>). <h2>Performance Related Assumptions</h2> <h2 id=fs_characteristics>System Failure Related Assumptions</h2> <p> In the event of an operating system or power failure, the various combinations of file-system and storage hardware available provide varying levels of guarantee as to the integrity of the data written to the file system just before or during the failure. The exact |
︙ | ︙ | |||
200 201 202 203 204 205 206 | crash occured. <p> Assuming that any and all sectors in the transient state may be corrupted following a power or system failure is a very pessimistic approach. Some modern systems provide more sophisticated guarantees than this. SQLite allows the VFS implementation to specify at runtime | | | 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 | crash occured. <p> Assuming that any and all sectors in the transient state may be corrupted following a power or system failure is a very pessimistic approach. Some modern systems provide more sophisticated guarantees than this. SQLite allows the VFS implementation to specify at runtime that the current platform supports zero or more of the following properties: <ul> <li><p>The <b>safe-append</b> property. If a system supports the <i>safe-append</i> property, it means that when a file is extended the new data is written to the persistent media before the size of the file itself is updated. This guarantees that if a failure |
︙ | ︙ |